wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
httpx.h File Reference

Small conveniences for a wired_http_handler filling its exchange. More...

Go to the source code of this file.

Functions

int wired_http_reply_text (wired_http_exchange *x, u16 status, const char *text)
 Answer x with a text/plain body: sets status (0 = 200), content_type and appends text to x->body (cut to what fits).
int wired_http_add_field (wired_http_exchange *x, const char *name, const char *value)
 Append the response header field name: value to x (first round only).

Detailed Description

Small conveniences for a wired_http_handler filling its exchange.

Function Documentation

◆ wired_http_add_field()

int wired_http_add_field ( wired_http_exchange * x,
const char * name,
const char * value )

Append the response header field name: value to x (first round only).

Both strings are views and must outlive the round (string literals do).

Parameters
xexchange being answered
namelowercase field name, NUL-terminated
valuefield value, NUL-terminated
Returns
1 ok, 0 if x already holds WIRED_HTTP_MAX_FIELDS fields

◆ wired_http_reply_text()

int wired_http_reply_text ( wired_http_exchange * x,
u16 status,
const char * text )

Answer x with a text/plain body: sets status (0 = 200), content_type and appends text to x->body (cut to what fits).

Parameters
xexchange being answered
statusresponse status, 0 for 200
textNUL-terminated body text
Returns
1, so a handler can return wired_http_reply_text(...)