HTTP client¶
A resource that provides support for making HTTP requests.
- class vxsandbox.resources.http.HttpClientResource(name, app_worker, config)[source]¶
Resource that allows making HTTP calls to outside services.
All command on this resource share a common set of command and response fields:
- Command fields:
url: The URL to request
- verify_options: A list of options to verify when doing
an HTTPS request. Possible string values are VERIFY_NONE, VERIFY_PEER, VERIFY_CLIENT_ONCE and VERIFY_FAIL_IF_NO_PEER_CERT. Specifying multiple values results in passing along a reduced OR value (e.g. VERIFY_PEER | VERIFY_FAIL_IF_NO_PEER_CERT)
- headers: A dictionary of keys for the header name and a list
of values to provide as header values.
data: The payload to submit as part of the request.
- files: A dictionary, submitted as multipart/form-data
in the request:
[{ "field name": { "file_name": "the file name", "content_type": "content-type", "data": "data to submit, encoded as base64", } }, ...]
The data field in the dictionary will be base64 decoded before the HTTP request is made.
- Success reply fields:
- success: Set to true
- body: The response body
- code: The HTTP response code
- Failure reply fields:
- success: set to false
- reason: Reason for the failure
Example:
api.request( 'http.get', {url: 'http://foo/'}, function(reply) { api.log_info(reply.body); });
- agent_class¶
alias of Agent