oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
net_http.h
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
24#include "ove/types.h"
25#include "ove/net.h"
26#include "ove_config.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
40
44typedef struct {
45 const char *name;
46 const char *value;
48
52typedef struct {
53 int status;
54 char *body;
55 size_t body_len;
56 char *headers;
57 size_t headers_len;
59
60#include "ove/storage.h"
61
62#ifdef CONFIG_OVE_NET_HTTP
63
71int ove_http_client_init(ove_http_client_t *client,
72 ove_http_client_storage_t *storage);
73
79void ove_http_client_deinit(ove_http_client_t client);
80
89int ove_http_get(ove_http_client_t client, const char *url,
91
103int ove_http_post(ove_http_client_t client, const char *url,
104 const char *content_type,
105 const void *body, size_t body_len,
106 ove_http_response_t *resp);
107
120int ove_http_request(ove_http_client_t client,
121 ove_http_method_t method, const char *url,
122 const char *content_type,
123 const void *body, size_t body_len,
124 ove_http_response_t *resp);
125
140int ove_http_request_ex(ove_http_client_t client,
141 ove_http_method_t method, const char *url,
142 const char *content_type,
143 const void *body, size_t body_len,
144 const ove_http_header_t *headers,
145 size_t header_count,
146 ove_http_response_t *resp);
147
153void ove_http_response_free(ove_http_response_t *resp);
154
155#ifdef OVE_HEAP_NET_HTTP
162int ove_http_client_create(ove_http_client_t *client);
163
169void ove_http_client_destroy(ove_http_client_t client);
170#endif /* OVE_HEAP_NET_HTTP */
171
172#else /* !CONFIG_OVE_NET_HTTP */
173
175#ifndef CONFIG_OVE_NET_HTTP
176typedef struct { uint8_t _unused; } ove_http_client_storage_t;
177#endif
178
179static inline int ove_http_client_init(ove_http_client_t *client, ove_http_client_storage_t *storage) { (void)client; (void)storage; return OVE_ERR_NOT_SUPPORTED; }
180static inline void ove_http_client_deinit(ove_http_client_t client) { (void)client; }
181static inline int ove_http_get(ove_http_client_t client, const char *url, ove_http_response_t *resp) { (void)client; (void)url; (void)resp; return OVE_ERR_NOT_SUPPORTED; }
182static inline 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) { (void)client; (void)url; (void)content_type; (void)body; (void)body_len; (void)resp; return OVE_ERR_NOT_SUPPORTED; }
183static inline 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) { (void)client; (void)method; (void)url; (void)content_type; (void)body; (void)body_len; (void)resp; return OVE_ERR_NOT_SUPPORTED; }
184static inline 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) { (void)client; (void)method; (void)url; (void)content_type; (void)body; (void)body_len; (void)headers; (void)header_count; (void)resp; return OVE_ERR_NOT_SUPPORTED; }
185static inline void ove_http_response_free(ove_http_response_t *resp) { (void)resp; }
188#endif /* CONFIG_OVE_NET_HTTP */
189
190#ifdef __cplusplus
191}
192#endif
193
196#endif /* OVE_NET_HTTP_H */
ove_http_method_t
HTTP method.
Definition net_http.h:33
@ OVE_HTTP_POST
Definition net_http.h:35
@ OVE_HTTP_DELETE
Definition net_http.h:37
@ OVE_HTTP_GET
Definition net_http.h:34
@ OVE_HTTP_PUT
Definition net_http.h:36
@ OVE_HTTP_PATCH
Definition net_http.h:38
#define OVE_ERR_NOT_SUPPORTED
The requested feature is not supported by the active backend.
Definition types.h:38
struct ove_http_client * ove_http_client_t
Opaque handle for an HTTP client.
Definition types.h:130
HTTP request header (name-value pair).
Definition net_http.h:44
const char * value
Definition net_http.h:46
const char * name
Definition net_http.h:45
HTTP response (returned by request functions).
Definition net_http.h:52
int status
Definition net_http.h:53
size_t body_len
Definition net_http.h:55
char * body
Definition net_http.h:54
size_t headers_len
Definition net_http.h:57
char * headers
Definition net_http.h:56