HTTP
class HTTP
HTTP(timeout=5000, ctx=())
Create an HTTP object by initializing http/https connection parameters according to the ctx
sequence. The timeout
, in milliseconds, is used for connections timeout.
The ctx
sequence is composed as in the following:
cacert
: a bytearray for the Certification Authority certificate.clicert
: a bytearray for the client certificate.clikey
: a bytearray for the client private key.verify
: aBool
that specifies whether the client has to be verified be the server or not.global
: aBool
that specifies whether the global context has to be used or not.sec
: aBool
that specifies whether to use hardware secure element or not.
method get
get(url, headers={})
Sends a GET request to the url
with the optional header
dictionary.
Returns a Response
object with the server reply.
method post
post(url, headers={}, body="")
Sends a POST request to the url
with the optional header
dictionary and the body
string containing the POST data.
Returns a Response
object with the server reply.
method put
put(url, headers={}, body="")
Sends a PUT request to the url
with the optional header
dictionary and the body
string containing the PUT data.
Returns a Response
object with the server reply.
method patch
patch(url, headers={}, body="")
Sends a PATCH request to the url
with the optional header
dictionary and the body
string containing the PATCH data.
Returns a Response
object with the server reply.
method delete
delete(url, headers={}, body="")
Sends a DELETE request to the url
with the optional header
dictionary and the body
string containing the DELETE data.
Returns a Response
object with the server reply.
method head
head(url, headers={})
Sends a HEAD request to the url
with the optional header
dictionary.
Returns a Response
object with the server reply.
method download
download(url, fd, headers={})
Sends a DOWNLOAD request to the url
with the optional header
dictionary and save the returning stream to fd
file descriptor. If -1
is passed as fd
the stream data is returned into the Response
object.
Returns a Response
object with the server reply.
method destroy
destroy()
Closes the http/https connection, de-initialize the configured connection and all resources freed.
class Response
Response(status, data, headers)
This class is used to contain HTTP methods responses. The class attributes are:
status
is the HTTP return status from the server, as integer.data
stream data when available, as bytearrayheaders
is the set of HTTP headers associated to the request, as dictionary.