Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: MQTTGateway2 MQTTGatewayK64 http-example-wnc GuardRoom ... more
HttpRequest Class Reference
HttpRequest implements the logic for interacting with HTTP servers. More...
#include <http_request.h>
Inherits HttpRequestBase.
Public Member Functions | |
| HttpRequest (NetworkInterface *network, http_method method, const char *url, Callback< void(const char *at, uint32_t length)> bodyCallback=0) | |
| HttpRequest Constructor. | |
| HttpRequest (TCPSocket *socket, http_method method, const char *url, Callback< void(const char *at, uint32_t length)> bodyCallback=0) | |
| HttpRequest Constructor. | |
| HttpResponse * | send (const void *body=NULL, nsapi_size_t body_size=0) |
| Execute the request and receive the response. | |
| HttpResponse * | send (Callback< const void *(uint32_t *)> body_cb) |
| Execute the request and receive the response. | |
| void | set_header (string key, string value) |
| Set a header for the request. | |
| nsapi_error_t | get_error () |
| Get the error code. | |
| void | set_request_log_buffer (uint8_t *buffer, size_t buffer_size) |
| Set the request log buffer, all bytes that are sent for this request are logged here. | |
| size_t | get_request_log_buffer_length () |
| Get the number of bytes written to the request log buffer, since the last request. | |
Friends | |
| class | HttpRequestBase |
Detailed Description
HttpRequest implements the logic for interacting with HTTP servers.
Definition at line 40 of file http_request.h.
Constructor & Destructor Documentation
| HttpRequest | ( | NetworkInterface * | network, |
| http_method | method, | ||
| const char * | url, | ||
| Callback< void(const char *at, uint32_t length)> | bodyCallback = 0 |
||
| ) |
HttpRequest Constructor.
- Parameters:
-
[in] network The network interface [in] method HTTP method to use [in] url URL to the resource [in] bodyCallback Callback on which to retrieve chunks of the response body. If not set, the complete body will be allocated on the HttpResponse object, which might use lots of memory.
Definition at line 54 of file http_request.h.
| HttpRequest | ( | TCPSocket * | socket, |
| http_method | method, | ||
| const char * | url, | ||
| Callback< void(const char *at, uint32_t length)> | bodyCallback = 0 |
||
| ) |
HttpRequest Constructor.
- Parameters:
-
[in] socket An open TCPSocket [in] method HTTP method to use [in] url URL to the resource [in] bodyCallback Callback on which to retrieve chunks of the response body. If not set, the complete body will be allocated on the HttpResponse object, which might use lots of memory.
Definition at line 78 of file http_request.h.
Member Function Documentation
| nsapi_error_t get_error | ( | ) | [inherited] |
Get the error code.
When send() fails, this error is set.
Definition at line 210 of file http_request_base.h.
| size_t get_request_log_buffer_length | ( | ) | [inherited] |
Get the number of bytes written to the request log buffer, since the last request.
If no request was sent, or if the request log buffer is NULL, then this returns 0.
Definition at line 231 of file http_request_base.h.
| HttpResponse* send | ( | const void * | body = NULL, |
| nsapi_size_t | body_size = 0 |
||
| ) | [inherited] |
Execute the request and receive the response.
This adds a Content-Length header to the request (when body_size is set), and sends the data to the server.
- Parameters:
-
body Pointer to the body to be sent body_size Size of the body to be sent
- Returns:
- An HttpResponse pointer on success, or NULL on failure. See get_error() for the error code.
Definition at line 88 of file http_request_base.h.
| HttpResponse* send | ( | Callback< const void *(uint32_t *)> | body_cb ) | [inherited] |
Execute the request and receive the response.
This sends the request through chunked-encoding.
- Parameters:
-
body_cb Callback which generates the next chunk of the request
- Returns:
- An HttpResponse pointer on success, or NULL on failure. See get_error() for the error code.
Definition at line 120 of file http_request_base.h.
| void set_header | ( | string | key, |
| string | value | ||
| ) | [inherited] |
Set a header for the request.
The 'Host', 'Content-Length', and (optionally) 'Transfer-Encoding: chunked' headers are set automatically. Setting the same header twice will overwrite the previous entry.
- Parameters:
-
key Header key value Header value
Definition at line 201 of file http_request_base.h.
| void set_request_log_buffer | ( | uint8_t * | buffer, |
| size_t | buffer_size | ||
| ) | [inherited] |
Set the request log buffer, all bytes that are sent for this request are logged here.
If the buffer would overflow logging is stopped.
- Parameters:
-
buffer Pointer to a buffer to store the data in buffer_size Size of the buffer
Definition at line 221 of file http_request_base.h.
Generated on Wed Jul 13 2022 00:40:26 by
1.7.2