HSL 2.0 framework
Description of the framework
|
All methods of the HTTP client More..
Public Member Functions | |
def | __init__ (self, framework, context_map) |
Constructor. More... | |
def | set_url (self, method, url, http_version=1) |
Sets the URL to be called. More... | |
def | set_header (self, key, value) |
Sets a header. More... | |
def | set_body (self, data, content_type=None) |
Set the body. More... | |
def | set_on_data (self, callback) |
Specifies a callback method for the response. More... | |
def | set_on_error (self, callback) |
Specifies a callback method for errors. More... | |
def | start_request (self) |
Starts HTTP polling. More... | |
All methods of the HTTP client
Used for communication with a remote terminal via HTTP.
The following timeouts, which will disconnect the connection when they occur, must be observed:
def hsl20_4_http_client.hsl20_4_http_client.Client.__init__ | ( | self, | |
framework, | |||
context_map | |||
) |
Constructor
def hsl20_4_http_client.hsl20_4_http_client.client.set_body | ( | self, | |
data, | |||
content_type = None |
|||
) |
Set the body
Only needed for e.g. POST and GET. The method also sets the HTTP header "Content-length" based on the data passed under data
data | string Data |
content_type | string Optional, sets in the header the content-type of the data to be transmitted (default: None) Note added to the default value of parameter content_type |
def hsl20_4_http_client.hsl20_4_http_client.Client.set_header | ( | self, | |
key, | |||
value | |||
) |
Sets a header
For example: set_header("Content-type", "text/html")
Several headers can be defined
key | string Key of the header |
value | string Value |
def hsl20_4_http_client.hsl20_4_http_client.client.set_on_data | ( | self, | |
callback | |||
) |
Specifies a callback method for the response
The method is called when the remote party has completely answered the request or when an error has occurred.
The callback method requires the following parameters:
callback | function Callback method |
def hsl20_4_http_client.hsl20_4_http_client.Client.set_on_error | ( | self, | |
callback | |||
) |
Specifies a callback method for errors
The callback method is called when an error or timeout occurs during communication.
The callback method requires the following parameters:
callback | function Callback method |
def hsl20_4_http_client.hsl20_4_http_client.client.set_url | ( | self, | |
method, | |||
ancient, | |||
http_version = 1 |
|||
) |
Sets the URL to be called
method | string Retrieval method to be used for the URL (e.g. GET) |
url | string URL (e.g. http://www.example.net/) |
http_version | int Optional. HTTP version.
|
ValueError | Dispatched when an invalid URL is supplied |
ValueError | Dispatched when an invalid HTTP version is submitted |
def hsl20_4_http_client.hsl20_4_http_client.client.start_request | ( | self | ) |
Starts HTTP polling
Triggers an exception if not all attributes required for the request are set
AttributeError | Triggers an exception if not all attributes required for the retrieval are set |
RuntimeError | Triggers an exception if the host name could not be resolved |
RuntimeError | Triggers an exception if the method has already been called |