HttpQuery-options
This JSON structure is used to configure various parameters for HTTP requests sent by HttpQuery and HttpQuery_Go functions.
Attributes
| Name | Type | Description |
method | string | HTTP request method, for example: |
body | string | Request body content. For example, in POST requests, body can contain form data, JSON data, text, etc. |
charset | string | Character set of the response. When set, the response body is decoded from this character set into UTF-8 text, for example |
cookie | string | Cookie is a small piece of data used to store and exchange state information between the client (usually a browser) and the server. |
debug | bool | Debug mode switch. When set to true, the HttpQuery function call will return the complete HTTP response message; when set to false, it only returns the data in the response message Body. |
headers | object | HTTP request header information, existing as key-value pairs (JSON structure), used to pass various information such as content type, authentication information, cache control, etc. |
proxy | string | Proxy for this request. Supports |
timeout | number | Timeout setting in milliseconds. Setting 1000 means 1 second timeout. Defaults to 300000 (5 minutes) when not set. |
See Also
Remarks
Usage example:
javascript
function main() {
var options = {
method: "POST",
body: "a=10&b=20&c=30",
charset: "UTF-8",
cookie: "session_id=12345; lang=en",
debug: false,
headers: {"TEST-HTTP-QUERY": "123"},
timeout: 1000
}
var ret = HttpQuery("http://127.0.0.1:8080", options)
Log(ret)
}
HTTP message sent when the above code is executed:
log
POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Cookie: session_id=12345; lang=en
Host: 127.0.0.1:8080
Test-Http-Query: 123
Content-Length: 14
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) ...
Accept-Encoding: gzip, br
a=10&b=20&c=30