Lua HTTP functions
dw.http.get
status, body, headers = dw.http.get(url, headers, timeout)
Description
Gets the content specified by the "url" parameter, header properties are specified in the headers table input into the function. The function returns the status (HTTP Status codes), the body, and the headers as 3 parameters. The headers are returned as a table for easy access.
Inputs
- url: a STRING value of the URL. Supports both http:// or https://
- headers: a table of string/string key/value pairs
- timeout: a INT timeout value
Outputs
- status: the HTTP Status code
- body: the returned body
- headers: a table of string/string key/value pairs
Example usage
These example Lua files show the usage of the dw.http.get function:
dw.http.post
status, body, headers = dw.http.post(url, headers, data)
Description
Posts the data to the specified URL. Information can be returned with the same definitions as the http.get function.
Inputs
- url: a STRING value of the URL. Supports both http:// or https://
- headers: a table of string/string key/value pairs
- data: a STRING, the data to post
Outputs
- status: the HTTP Status code
- body:
- headers: a table of string/string key/value pairs
Example usage
This example Lua file shows the usage of the dw.http.post function: