gs.form API Reference¶
The package exports the following API symbol.
- gs.form.post_multipart(netloc, selector, fields, files=, []usessl=False)¶
Post fields and files to an http host as multipart/form-data.
Parameters: - netloc (str) – The netloc (host or host:port).
- selector (str) – The path to the form that will be posted to.
- fields (list) – A sequence of (name, value) 2-tuple elements for regular form fields.
- files (list) – A sequence of (name, filename, value) 3-tuple elements for data to be uploaded as files
- usessl (bool) – True if TLS should be used to communicate with the server.
Returns: A 3-tuple: the reponse-status, reason, and data.
Example:
Post three normal form fields (parrot, piranah, and ethyl) and one file (the text file rule.txt, sent as the unwritten form field) to example.com on port 2585, using normal HTTP rather than TLS (the default):
fields = [('parrot', 'dead'), ('piranha', 'brother'), ('ethyl', 'frog')] files = [('unwritten', 'rule.txt', 'This is a transgression.')] r = post_multipart('example.com:2585', '/form.html', fields, files) status, reason, data = r
Internals¶
In addition to the post_multipart() function, the following are used internally.
- class gs.form.postmultipart.Connection(netloc, usessl=False)[source]¶
A wrapper for the HTTP(S) connection