Http - stingray.Http namespace reference - Stingray Lua API Reference
Implements a simple HTTP client.
Note that this simple client does not
support advanced features such as SSL. If you need that you should use the plugin
system to link to a more advanced HTTP client, such as Curl.
The Http object is a global singleton and all functions operate on this global
singleton.
|
Status of a HTTP operation.
|
|
Closes the specified request and frees all associated memory.
|
Parameters id : | integer | The ID of the operation. |
Returns | This function does not return any values. |
After
you have called close() you can no longer obtain any information
about the request.
|
Returns the error message of a HTTP operation with the ERROR status.
|
Parameters id : | integer | The ID of the operation. |
Returns string? |
The error of the HTTP operation.
The ? notation indicates that this type is optional: there may be zero or one instances of it. |
If the status is not ERROR, nil is returned.
|
get ( url, timeout ) : integer
Starts an asynchronous HTTP GET operation to fetch the specified resource.
|
Parameters url : | string | The URL of the resource we should GET. |
timeout : | number? | The timeout in seconds after which the request will automatically fail (default 10s). The ? notation indicates that this type is optional: there may be zero or one instances of it. |
Returns integer |
An ID identifying this request.
|
You can use the returned ID to monitor the progress of the operation.
The request will automatically close after the specified timeout, but to
conserve memory you should close your requests manually when you are
done with them.
|
post ( url, content_type, body, timeout ) : integer
Starts an asynchronous HTTP POST operation.
|
Parameters url : | string | The URL of the endpoint we should POST to. |
content_type : | string | The content type of the POST request |
body : | string | The body of the POST request |
timeout : | number? | The timeout in seconds after which the request will automatically fail (default 10s). The ? notation indicates that this type is optional: there may be zero or one instances of it. |
Returns integer |
An ID identifying this request.
|
You can use the returned ID to monitor the progress of the operation.
The request will automatically close after the specified timeout, but to
conserve memory you should close your requests manually when you are
done with them.
|
Returns the result of a HTTP operation that has FINISHED.
|
Parameters id : | integer | The ID of the operation. |
Returns table? |
The result of the HTTP operation.
The ? notation indicates that this type is optional: there may be zero or one instances of it. |
If the
operation has not FINISHED, nil is returned.
The result is returned as a table with the following fields:
- status_code: The HTTP status code as an integer.
- reason_phrase: The HTTP reason phrase associated with the status code.
- headers: A table with the keys and values of the HTTP headers.
- body: The body of the HTTP data.
|
status ( id ) : stingray.Http.Status
Returns the current status of the HTTP operation.
|
Parameters id : | integer | The ID of the operation. |
Returns