Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_http3.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
41#ifndef __NILOREA_HTTP3_HEADER
42#define __NILOREA_HTTP3_HEADER
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48#include <stddef.h>
49
56#define N_HTTP3_DEFAULT_TIMEOUT_MS 15000
58#define N_HTTP3_BODY_CAP (16u * 1024u * 1024u)
59
66#define N_HTTP3_REQ_ALLOW_ILLEGAL_HEADERS 1u
67
69typedef struct N_HTTP3_RESPONSE {
70 int status;
71 char* headers;
72 unsigned char* body;
73 size_t body_len;
74 char* error;
76
81int n_http3_available(void);
82
99int n_http3_parse_url(const char* url, char* host, size_t hostsz, char* port, size_t portsz, char* path, size_t pathsz);
100
118int n_http3_request(const char* method, const char* url, const char* headers, const unsigned char* body, size_t body_len, int timeout_ms, N_HTTP3_RESPONSE* out);
119
141int n_http3_request_ex(const char* method, const char* url, const char* headers, const unsigned char* body, size_t body_len, int timeout_ms, unsigned flags, N_HTTP3_RESPONSE* out);
142
150int n_http3_get(const char* url, int timeout_ms, N_HTTP3_RESPONSE* out);
151
157
160#ifdef __cplusplus
161}
162#endif
163
164#endif /* __NILOREA_HTTP3_HEADER */
char * port
char * headers
Response header block as joined "name: value\r\n" lines (lowercased names), or NULL.
Definition n_http3.h:71
int status
HTTP status code, or 0 if none was received.
Definition n_http3.h:70
size_t body_len
Number of valid bytes in body.
Definition n_http3.h:73
unsigned char * body
Response body bytes (NOT NUL-terminated), or NULL.
Definition n_http3.h:72
char * error
Failure reason (heap), or NULL on a completed exchange.
Definition n_http3.h:74
int n_http3_parse_url(const char *url, char *host, size_t hostsz, char *port, size_t portsz, char *path, size_t pathsz)
Split an https URL into host, port and path (pure; available in every build).
Definition n_http3.c:57
int n_http3_request_ex(const char *method, const char *url, const char *headers, const unsigned char *body, size_t body_len, int timeout_ms, unsigned flags, N_HTTP3_RESPONSE *out)
Perform one blocking HTTP/3 request, with request flags.
Definition n_http3.c:1123
int n_http3_get(const char *url, int timeout_ms, N_HTTP3_RESPONSE *out)
Convenience wrapper: HTTP/3 GET of url.
Definition n_http3.c:128
int n_http3_request(const char *method, const char *url, const char *headers, const unsigned char *body, size_t body_len, int timeout_ms, N_HTTP3_RESPONSE *out)
Perform one blocking HTTP/3 request over a fresh QUIC connection.
Definition n_http3.c:1108
int n_http3_available(void)
Report whether HTTP/3 support was compiled into the library.
Definition n_http3.c:1104
void n_http3_response_free(N_HTTP3_RESPONSE *r)
Free the heap buffers held by r and zero the struct (safe on NULL / zeroed).
Definition n_http3.c:43
Result of an HTTP/3 exchange.
Definition n_http3.h:69