2024-08-18 16:56:05 +02:00
|
|
|
/**
|
|
|
|
* HTTP client
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
2024-08-23 23:06:14 +02:00
|
|
|
enum method
|
|
|
|
{
|
|
|
|
MethodGET = 0,
|
|
|
|
MethodPOST
|
|
|
|
};
|
|
|
|
|
2024-08-18 16:56:05 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2024-08-23 21:00:18 +02:00
|
|
|
const char *url;
|
2024-08-18 20:13:03 +02:00
|
|
|
char *root_ca;
|
2024-08-23 23:06:14 +02:00
|
|
|
const char *body;
|
|
|
|
const char *content_type;
|
|
|
|
enum method method;
|
2024-08-18 16:56:05 +02: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 23:06:14 +02: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 16:56:05 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|