oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
net_http.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 Kamil Lulko <kamil.lulko@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 *
6 * This file is part of oveRTOS.
7 */
8
9#ifndef OVE_NET_HTTP_H
10#define OVE_NET_HTTP_H
11
25#include "ove/types.h"
26#include "ove/net.h"
27#include "ove_config.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
41
45typedef struct {
46 const char *name;
47 const char *value;
49
53typedef struct {
54 int status;
55 char *body;
56 size_t body_len;
57 char *headers;
58 size_t headers_len;
60
61#include "ove/storage.h"
62
63#ifdef CONFIG_OVE_NET_HTTP
64
72int ove_http_client_init(ove_http_client_t *client, ove_http_client_storage_t *storage);
73
80
89int ove_http_get(ove_http_client_t client, const char *url, ove_http_response_t *resp);
90
102int ove_http_post(ove_http_client_t client, const char *url, const char *content_type,
103 const void *body, size_t body_len, ove_http_response_t *resp);
104
117int ove_http_request(ove_http_client_t client, ove_http_method_t method, const char *url,
118 const char *content_type, const void *body, size_t body_len,
119 ove_http_response_t *resp);
120
135int ove_http_request_ex(ove_http_client_t client, ove_http_method_t method, const char *url,
136 const char *content_type, const void *body, size_t body_len,
137 const ove_http_header_t *headers, size_t header_count,
138 ove_http_response_t *resp);
139
146
147#ifdef OVE_HEAP_NET_HTTP
155
162#endif /* OVE_HEAP_NET_HTTP */
163
164#else /* !CONFIG_OVE_NET_HTTP */
165
167#ifndef CONFIG_OVE_NET_HTTP
168typedef struct {
169 uint8_t _unused;
170} ove_http_client_storage_t;
171#endif
172
173static inline int ove_http_client_init(ove_http_client_t *client,
174 ove_http_client_storage_t *storage)
175{
176 (void)client;
177 (void)storage;
179}
180static inline void ove_http_client_deinit(ove_http_client_t client)
181{
182 (void)client;
183}
184static inline int ove_http_get(ove_http_client_t client, const char *url, ove_http_response_t *resp)
185{
186 (void)client;
187 (void)url;
188 (void)resp;
190}
191static inline int ove_http_post(ove_http_client_t client, const char *url, const char *content_type,
192 const void *body, size_t body_len, ove_http_response_t *resp)
193{
194 (void)client;
195 (void)url;
196 (void)content_type;
197 (void)body;
198 (void)body_len;
199 (void)resp;
201}
202static inline int ove_http_request(ove_http_client_t client, ove_http_method_t method,
203 const char *url, const char *content_type, const void *body,
204 size_t body_len, ove_http_response_t *resp)
205{
206 (void)client;
207 (void)method;
208 (void)url;
209 (void)content_type;
210 (void)body;
211 (void)body_len;
212 (void)resp;
214}
215static inline int ove_http_request_ex(ove_http_client_t client, ove_http_method_t method,
216 const char *url, const char *content_type, const void *body,
217 size_t body_len, const ove_http_header_t *headers,
218 size_t header_count, ove_http_response_t *resp)
219{
220 (void)client;
221 (void)method;
222 (void)url;
223 (void)content_type;
224 (void)body;
225 (void)body_len;
226 (void)headers;
227 (void)header_count;
228 (void)resp;
230}
231static inline void ove_http_response_free(ove_http_response_t *resp)
232{
233 (void)resp;
234}
237#endif /* CONFIG_OVE_NET_HTTP */
238
239#ifdef __cplusplus
240}
241#endif
242
245#endif /* OVE_NET_HTTP_H */
void ove_http_client_deinit(ove_http_client_t client)
De-initialise an HTTP client.
ove_http_method_t
HTTP method.
Definition net_http.h:34
int ove_http_request(ove_http_client_t client, ove_http_method_t method, const char *url, const char *content_type, const void *body, size_t body_len, ove_http_response_t *resp)
Perform a generic HTTP request.
int ove_http_request_ex(ove_http_client_t client, ove_http_method_t method, const char *url, const char *content_type, const void *body, size_t body_len, const ove_http_header_t *headers, size_t header_count, ove_http_response_t *resp)
Perform an HTTP request with custom headers.
void ove_http_client_destroy(ove_http_client_t client)
Destroy a heap-allocated HTTP client.
int ove_http_get(ove_http_client_t client, const char *url, ove_http_response_t *resp)
Perform an HTTP GET request.
int ove_http_client_init(ove_http_client_t *client, ove_http_client_storage_t *storage)
Initialise an HTTP client from caller-supplied storage.
int ove_http_post(ove_http_client_t client, const char *url, const char *content_type, const void *body, size_t body_len, ove_http_response_t *resp)
Perform an HTTP POST request.
void ove_http_response_free(ove_http_response_t *resp)
Free resources in an HTTP response.
int ove_http_client_create(ove_http_client_t *client)
Heap-allocate and initialise an HTTP client.
@ OVE_HTTP_POST
Definition net_http.h:36
@ OVE_HTTP_DELETE
Definition net_http.h:38
@ OVE_HTTP_GET
Definition net_http.h:35
@ OVE_HTTP_PUT
Definition net_http.h:37
@ OVE_HTTP_PATCH
Definition net_http.h:39
struct ove_http_client * ove_http_client_t
Opaque handle for an HTTP client.
Definition types.h:256
@ OVE_ERR_NOT_SUPPORTED
Definition types.h:98
HTTP request header (name-value pair).
Definition net_http.h:45
const char * value
Definition net_http.h:47
const char * name
Definition net_http.h:46
HTTP response (returned by request functions).
Definition net_http.h:53
int status
Definition net_http.h:54
size_t body_len
Definition net_http.h:56
char * body
Definition net_http.h:55
size_t headers_len
Definition net_http.h:58
char * headers
Definition net_http.h:57