reqwest.send
reqwest.send
Function
Send HTTP requests synchronously and return response objects.
Syntax
reqwest(url).send()
Parameters
No parameters.
Return value
| Type | Description |
|---|---|
| Object | Returns the HTTP response object. |
Response object fields
| Field | Type | Must exist | Description |
|---|---|---|---|
| status | Int | Yes | HTTP response status code, such as 200, 404, 500. |
| body | String | Yes | The response body text. |
| headers | Object | Yes | The response header object. The key is the response header name and the value is the response header string value. |
Example
// Send a GET request and read the HTTP status code. response = reqwest('https://example.com').send() result = response.status // Example output: 200 print result
Notes
- send() will wait for the request to be completed synchronously; the underlying layer reuses the process-level I/O runtime.
- The HTTP client pool is enabled by default, and clients are grouped and reused according to proxy and redirection policies; a single timeout does not participate in the pool key and will still take effect according to this request.
- Requests that enable
cookie_store(true)will not enter the shared client pool, and the cookie is only retained in this sending and redirection link. - You can view the number of pool entries, hits, eliminations, creation failures and slow calls through
BT.stats().http.