Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_http3.h File Reference

Minimal blocking HTTP/3 (over QUIC) client. More...

#include <stddef.h>
+ Include dependency graph for n_http3.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  N_HTTP3_RESPONSE
 Result of an HTTP/3 exchange. More...
 

Macros

#define N_HTTP3_BODY_CAP   (16u * 1024u * 1024u)
 Hard cap on the response body kept in memory (bytes).
 
#define N_HTTP3_DEFAULT_TIMEOUT_MS   15000
 Default per-request budget (milliseconds) when the caller passes <= 0.
 
#define N_HTTP3_REQ_ALLOW_ILLEGAL_HEADERS   1u
 n_http3_request_ex flag: send the caller's extra headers WITHOUT the built-in connection-specific / framing filter (so an otherwise-forbidden header such as transfer-encoding, connection or upgrade reaches the wire).
 

Functions

int n_http3_available (void)
 Report whether HTTP/3 support was compiled into the library.
 
int n_http3_get (const char *url, int timeout_ms, N_HTTP3_RESPONSE *out)
 Convenience wrapper: HTTP/3 GET of url.
 
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).
 
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.
 
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.
 
void n_http3_response_free (N_HTTP3_RESPONSE *r)
 Free the heap buffers held by r and zero the struct (safe on NULL / zeroed).
 

Detailed Description

Minimal blocking HTTP/3 (over QUIC) client.

Author
Castagnier Mickael
Version
1.0

A small blocking HTTP/3 client built on ngtcp2 (QUIC transport) + nghttp3 (HTTP/3 framing and QPACK), using the OpenSSL native QUIC TLS handshake through the ngtcp2 "ossl" crypto shim. It performs a single request/response exchange over a fresh QUIC connection and returns the status, response headers, and body.

The whole implementation is compiled only when the library is built with HAVE_HTTP3 defined (opt-in, because it pulls the ngtcp2/nghttp3/OpenSSL h3 stack). Without it the functions still exist but report that HTTP/3 is not available, so callers link unconditionally and probe with n_http3_available(). The URL parser is a pure helper available in both builds.

Active outbound requests must target only authorized hosts.

Definition in file n_http3.h.