Fork of mbed-http
Fork of mbed-http by
HttpRequest Class Reference
HttpRequest implements the logic for interacting with HTTPS servers. More...
#include <http_request.h>
Public Member Functions | |
HttpRequest (NetworkInterface *aNetwork, http_method aMethod, const char *url, Callback< void(const char *at, size_t length)> aBodyCallback=0) | |
HttpRequest Constructor. | |
HttpRequest (TCPSocket *aSocket, http_method aMethod, const char *url, Callback< void(const char *at, size_t length)> aBodyCallback=0) | |
HttpRequest Constructor. | |
~HttpRequest () | |
HttpRequest Constructor. | |
HttpResponse * | send (const void *body=NULL, nsapi_size_t body_size=0) |
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. |
Detailed Description
HttpRequest implements the logic for interacting with HTTPS servers.
Definition at line 39 of file http_request.h.
Constructor & Destructor Documentation
HttpRequest | ( | NetworkInterface * | aNetwork, |
http_method | aMethod, | ||
const char * | url, | ||
Callback< void(const char *at, size_t length)> | aBodyCallback = 0 |
||
) |
HttpRequest Constructor.
- Parameters:
-
[in] aNetwork The network interface [in] aMethod HTTP method to use [in] url URL to the resource [in] aBodyCallback 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 51 of file http_request.h.
HttpRequest | ( | TCPSocket * | aSocket, |
http_method | aMethod, | ||
const char * | url, | ||
Callback< void(const char *at, size_t length)> | aBodyCallback = 0 |
||
) |
HttpRequest Constructor.
- Parameters:
-
[in] aSocket An open TCPSocket [in] aMethod HTTP method to use [in] url URL to the resource [in] aBodyCallback 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 74 of file http_request.h.
~HttpRequest | ( | ) |
HttpRequest Constructor.
Definition at line 90 of file http_request.h.
Member Function Documentation
nsapi_error_t get_error | ( | ) |
Get the error code.
When send() fails, this error is set.
Definition at line 218 of file http_request.h.
HttpResponse* send | ( | const void * | body = NULL , |
nsapi_size_t | body_size = 0 |
||
) |
Execute the request and receive the response.
Definition at line 113 of file http_request.h.
void set_header | ( | string | key, |
string | value | ||
) |
Set a header for the request.
The 'Host' and 'Content-Length' headers are set automatically. Setting the same header twice will overwrite the previous entry.
- Parameters:
-
[in] key Header key [in] value Header value
Definition at line 209 of file http_request.h.
Generated on Wed Jul 13 2022 02:24:14 by
