HTTP and HTTPS library for Mbed OS 5
Dependents: MQTTGateway2 MQTTGatewayK64 http-example-wnc GuardRoom ... more
HttpRequestBase Class Reference
HttpRequest implements the logic for interacting with HTTP servers. More...
#include <http_request_base.h>
Inherited by HttpRequest, and HttpsRequest.
Public Member Functions | |
virtual | ~HttpRequestBase () |
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 | HttpRequest |
class | HttpsRequest |
Detailed Description
HttpRequest implements the logic for interacting with HTTP servers.
Definition at line 48 of file http_request_base.h.
Constructor & Destructor Documentation
virtual ~HttpRequestBase | ( | ) | [virtual] |
HttpRequest Constructor.
Definition at line 60 of file http_request_base.h.
Member Function Documentation
nsapi_error_t get_error | ( | ) |
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 | ( | ) |
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 |
||
) |
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 ) |
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 | ||
) |
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 | ||
) |
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