Application can create HTTP client, send HTTP request, receive HTTP response or close the HTTP session.
Libre_IoNewHttpClient(host, port, https, method, uri, headers, body)
Start a HTTP client.
- host - String, the string representation of IP or host name.
- port - Integer, the TCP port.
- https - Boolean, true for HTTPS connection; false for HTTP.
- method - String representing HTTP method, for example, GET, POST, PUT etc.
- url - String, the request Uri.
- headers - Table of headers as key/value pairs.
- body - The data to be posted, can be nil.
- The socket handle.
Note: The returned socket handle shall be used in HTTP read/write and close; as well as event subscription.
Get response from HTTP(S) client.
- fd - The socket handle.
- ok - Boolean, true if no error; otherwise false.
- result - Nil if still reading response (ok=true); a table if response has been retrived successfully.
- version - HTTP version string.
- code - HTTP response code string.
- status - HTTP response status string.
- headers - HTTP response headers. This object is table of key/value pairs.
- body - HTTP response body string. It could be string of binary data.