fix the problem http request with '\0' and fixx query string in url
Fork of mbed-http by
HttpsRequest Class Reference
HttpsRequest implements the logic for interacting with HTTPS servers. More...
#include <https_request.h>
Public Member Functions | |
HttpsRequest (NetworkInterface *net_iface, const char *ssl_ca_pem, http_method method, const char *url, Callback< void(const char *at, size_t length)> body_callback=0) | |
HttpsRequest Constructor Initializes the TCP socket, sets up event handlers and flags. | |
~HttpsRequest () | |
HttpsRequest Destructor. | |
HttpResponse * | send (const void *body=NULL, nsapi_size_t body_size=0) |
Execute the HTTPS request. | |
void | close () |
Closes the TCP socket. | |
void | set_header (string key, string value) |
Set a header for the request. | |
nsapi_error_t | get_error () |
Get the error code. | |
void | set_debug (bool debug) |
Set the debug flag. | |
Static Protected Member Functions | |
static void | print_mbedtls_error (const char *name, int err) |
Helper for pretty-printing mbed TLS error codes. | |
static void | my_debug (void *ctx, int level, const char *file, int line, const char *str) |
Debug callback for mbed TLS Just prints on the USB serial port. | |
static int | my_verify (void *data, mbedtls_x509_crt *crt, int depth, uint32_t *flags) |
Certificate verification callback for mbed TLS Here we only use it to display information on each cert in the chain. | |
static int | ssl_recv (void *ctx, unsigned char *buf, size_t len) |
Receive callback for mbed TLS. | |
static int | ssl_send (void *ctx, const unsigned char *buf, size_t len) |
Send callback for mbed TLS. |
Detailed Description
HttpsRequest implements the logic for interacting with HTTPS servers.
Definition at line 46 of file https_request.h.
Constructor & Destructor Documentation
HttpsRequest | ( | NetworkInterface * | net_iface, |
const char * | ssl_ca_pem, | ||
http_method | method, | ||
const char * | url, | ||
Callback< void(const char *at, size_t length)> | body_callback = 0 |
||
) |
HttpsRequest Constructor Initializes the TCP socket, sets up event handlers and flags.
- Parameters:
-
[in] net_iface The network interface [in] ssl_ca_pem String containing the trusted CAs [in] method HTTP method to use [in] url URL to the resource [in] body_callback 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 60 of file https_request.h.
~HttpsRequest | ( | ) |
HttpsRequest Destructor.
Definition at line 86 of file https_request.h.
Member Function Documentation
void close | ( | ) |
Closes the TCP socket.
Definition at line 287 of file https_request.h.
nsapi_error_t get_error | ( | ) |
Get the error code.
When send() fails, this error is set.
Definition at line 309 of file https_request.h.
static void my_debug | ( | void * | ctx, |
int | level, | ||
const char * | file, | ||
int | line, | ||
const char * | str | ||
) | [static, protected] |
Debug callback for mbed TLS Just prints on the USB serial port.
Definition at line 337 of file https_request.h.
static int my_verify | ( | void * | data, |
mbedtls_x509_crt * | crt, | ||
int | depth, | ||
uint32_t * | flags | ||
) | [static, protected] |
Certificate verification callback for mbed TLS Here we only use it to display information on each cert in the chain.
Definition at line 359 of file https_request.h.
static void print_mbedtls_error | ( | const char * | name, |
int | err | ||
) | [static, protected] |
Helper for pretty-printing mbed TLS error codes.
Definition at line 326 of file https_request.h.
HttpResponse* send | ( | const void * | body = NULL , |
nsapi_size_t | body_size = 0 |
||
) |
Execute the HTTPS request.
- Parameters:
-
[in] body Pointer to the request body [in] body_size Size of the request body
- Returns:
- An HttpResponse pointer on success, or NULL on failure. See get_error() for the error code.
Definition at line 120 of file https_request.h.
void set_debug | ( | bool | debug ) |
Set the debug flag.
If this flag is set, debug information from mbed TLS will be logged to stdout.
Definition at line 318 of file https_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 300 of file https_request.h.
static int ssl_recv | ( | void * | ctx, |
unsigned char * | buf, | ||
size_t | len | ||
) | [static, protected] |
Receive callback for mbed TLS.
Definition at line 385 of file https_request.h.
static int ssl_send | ( | void * | ctx, |
const unsigned char * | buf, | ||
size_t | len | ||
) | [static, protected] |
Send callback for mbed TLS.
Definition at line 404 of file https_request.h.
Generated on Fri Jul 22 2022 08:07:18 by 1.7.2