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

n_http3 example + self-test: parse a URL (always) and, when built with HAVE_HTTP3, optionally fetch a live https URL over HTTP/3. More...

#include "nilorea/n_http3.h"
#include "nilorea/n_log.h"
#include <stdio.h>
#include <string.h>
+ Include dependency graph for ex_http3.c:

Go to the source code of this file.

Macros

#define CHECK(cond)
 tiny assert that keeps going and tallies failures
 

Functions

int main (int argc, char **argv)
 
static void test_parse_url (void)
 exercise the pure URL parser (runs in every build)
 
static void test_request_guards (void)
 exercise the request entry points' guards + delegation (deterministic, no network)
 

Variables

static int g_fails = 0
 test counter
 

Detailed Description

n_http3 example + self-test: parse a URL (always) and, when built with HAVE_HTTP3, optionally fetch a live https URL over HTTP/3.

Author
Castagnier Mickael
Version
1.0

Usage: ex_http3 [https://host/path]

The URL-parser checks run in every build and make this double as a unit test (a non-zero exit signals a failure). A live fetch is attempted only when a URL argument is given and the library was built with HAVE_HTTP3; against an authorized, reachable HTTP/3 host it prints the status, headers, and body size.

Definition in file ex_http3.c.

Macro Definition Documentation

◆ CHECK

#define CHECK (   cond)
Value:
do { \
if (!(cond)) { \
n_log(LOG_ERR, "CHECK failed: %s (%s:%d)", #cond, __FILE__, __LINE__); \
g_fails++; \
} \
} while (0)
static int g_fails
test counter
Definition ex_http3.c:42
#define LOG_ERR
error conditions
Definition n_log.h:76

tiny assert that keeps going and tallies failures

Definition at line 44 of file ex_http3.c.

Function Documentation

◆ main()

◆ test_parse_url()

static void test_parse_url ( void  )
static

exercise the pure URL parser (runs in every build)

Definition at line 53 of file ex_http3.c.

References CHECK, n_http3_parse_url(), and port.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ test_request_guards()

static void test_request_guards ( void  )
static

exercise the request entry points' guards + delegation (deterministic, no network)

Definition at line 82 of file ex_http3.c.

References CHECK, N_HTTP3_RESPONSE::error, N_HTTP3_REQ_ALLOW_ILLEGAL_HEADERS, n_http3_request(), n_http3_request_ex(), and n_http3_response_free().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ g_fails

int g_fails = 0
static

test counter

Definition at line 42 of file ex_http3.c.

Referenced by main().