HttpQuery-return
This JSON structure is the data structure returned by the HttpQuery function in debug mode, when the debug field is set to true in the options parameter structure while calling the HttpQuery function.
Attributes
| Name | Type | Description |
StatusCode | number | HTTP status code. It is 0 when no response is received for the request (connection refused, DNS resolution failure, timeout, proxy failure, etc.). |
Header | object | Response header information. The value of each key is an array of strings (a header name can appear several times, for example multiple |
Cookies | array | Array parsed from each |
Trace | object | Diagnostic timing information for each stage of the request, including millisecond values such as |
Length | number | Message length. When |
Body | string | Message content. It is an empty string when the request fails. |
Error | string | The reason for the request failure, including the request method, URL, and underlying error information, for example: |
See Also
Remarks
Example of the returned JSON data structure:
json
{
"StatusCode": 302,
"Header": {
"Content-Type": ["text/html"],
"Location": ["https://www.example.com/"]
},
"Cookies": [],
"Trace": {
"elapsed_ms": 152.4,
"dns_ms": 3.1,
"connect_ms": 20.5,
"tls_ms": 45.2,
"ttfb_ms": 150.8,
"recv_ms": 1.6,
"peer_addr": "93.184.216.34:443",
"reused": false,
"version": "HTTP/1.1"
},
"Length": 154,
"Body": "..."
}
Example of the data structure returned when the request fails (no response received):
json
{
"StatusCode": 0,
"Header": {},
"Cookies": [],
"Length": 0,
"Body": "",
"Error": "Get \"https://www.okx.com/api/v5/public/time\": timeout after 1000ms"
}
Responses with HTTP status codes 4xx and 5xx are not considered request failures. In this case, StatusCode is the actual status code, and the Error field is not included. You can use StatusCode for unified checking: if (ret.StatusCode !== 200) { ... }.
In Rust, the HttpRet structure returned by HttpQuery only has the fields StatusCode, Header, Cookies, Body and Error (there is no Length or Trace, and Cookies is not filled).