2024-08-18 14:56:05 +00:00
|
|
|
/**
|
|
|
|
* HTTP client
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
2024-08-23 21:06:14 +00:00
|
|
|
enum method
|
|
|
|
{
|
|
|
|
MethodGET = 0,
|
|
|
|
MethodPOST
|
|
|
|
};
|
|
|
|
|
2024-08-18 14:56:05 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2024-08-23 19:00:18 +00:00
|
|
|
const char *url;
|
2024-08-18 18:13:03 +00:00
|
|
|
char *root_ca;
|
2024-08-23 21:06:14 +00:00
|
|
|
const char *body;
|
|
|
|
const char *content_type;
|
|
|
|
enum method method;
|
2024-08-18 14:56:05 +00:00
|
|
|
} http_request_opts;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Perform an HTTP request.
|
|
|
|
*
|
|
|
|
* Returns NULL in case of failure or the response else. The memory
|
|
|
|
* must be released by the caller.
|
|
|
|
*/
|
|
|
|
char *http_client_exec(const http_request_opts *opts);
|
|
|
|
|
2024-08-23 21:06:14 +00:00
|
|
|
/**
|
|
|
|
* Escape URI string
|
|
|
|
*
|
|
|
|
* See protocol_example_utils.c of esp32-idf
|
|
|
|
*/
|
|
|
|
size_t http_client_escape_uri(unsigned char *dst, const unsigned char *src, size_t size);
|
|
|
|
|
2024-08-18 14:56:05 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|