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

RFC 9114 4.1 / 4.3.1, RFC 9204 4.5: drive HTTP/3 requests end to end: QPACK-encode and frame outgoing GET or arbitrary-method requests, and recover the pseudo-headers of received ones. More...

#include "app/http3/core/h3/priority.h"
#include "app/qpack/qpack/dyntable.h"
#include "common/bytes/span/span.h"
#include "common/platform/sys/syscall.h"

Go to the source code of this file.

Data Structures

struct  wired_h3reqdrive_get_in
 The :path and :authority values for a GET request. More...
struct  wired_h3reqdrive_send_in
 Remaining arguments of wired_h3reqdrive_send_method beyond stream_id/out: the request line (method/path/authority) and the optional body. More...
struct  wired_h3reqdrive_hdr
 One regular request header: name and value as octet positions inside the request's hdr_base (its decode scratch), so a copy of the request only has to move the bytes and re-point hdr_base. More...
struct  wired_h3reqdrive_req
 RFC 9114 4.1 / 4.3.1, RFC 9204 4.5: recovered request pseudo-headers. More...

Macros

#define WIRED_H3REQDRIVE_MAX_HDRS   32
 Regular request headers kept per request (see wired_h3reqdrive_req's hdrs); further ones are ignored.

Functions

int wired_h3reqdrive_send_get (u64 stream_id, const wired_h3reqdrive_get_in *in, wired_obuf *out)
 RFC 9114 4.1 / 4.3.1, RFC 9204 4.5: drive an HTTP/3 GET request end to end: QPACK-encode the request pseudo-headers (h3reqenc), wrap them in a HEADERS frame and a QUIC STREAM frame (h3conn).
int wired_h3reqdrive_send_method (u64 stream_id, const wired_h3reqdrive_send_in *in, wired_obuf *out)
 RFC 9114 4.1 / 4.3.1, RFC 9204 4.5: drive an arbitrary-method HTTP/3 request end to end: QPACK-encode the request pseudo-headers with the given :method, append a DATA frame when in->body is non-empty, and wrap in a STREAM frame.
static wired_span wired_h3req_path (const wired_h3reqdrive_req *r)
 The request's :path as one view (path, path_len).
int wired_http_req_header (const wired_h3reqdrive_req *req, wired_span name, wired_span *out)
 RFC 9114 4.2: find a regular request header by name.
int wired_h3reqdrive_recv_get (wired_span stream_data, wired_mspan scratch, wired_h3reqdrive_req *r)
 RFC 9114 4.1, RFC 9204 4.5: decode a STREAM frame carrying a request: recover :method, :scheme, :authority and :path from the leading HEADERS frame's QPACK field section.
int wired_h3reqdrive_recv_get_dyn (wired_span stream_data, wired_mspan scratch, const qpack_dyn *dyn, wired_h3reqdrive_req *r)
 Same as wired_h3reqdrive_recv_get, but also resolves dynamic-table references (RFC 9204 4.5.2/4.5.3 Indexed Field Line / Indexed Field Line with Post-Base Index) against dyn – the connection's QPACK dynamic table (0 behaves exactly like wired_h3reqdrive_recv_get: every dynamic reference then simply fails to resolve).

Detailed Description

RFC 9114 4.1 / 4.3.1, RFC 9204 4.5: drive HTTP/3 requests end to end: QPACK-encode and frame outgoing GET or arbitrary-method requests, and recover the pseudo-headers of received ones.

Function Documentation

◆ wired_h3req_path()

wired_span wired_h3req_path ( const wired_h3reqdrive_req * r)
inlinestatic

The request's :path as one view (path, path_len).

Parameters
rdecoded request
Returns
view of the path; valid as long as r is

◆ wired_h3reqdrive_recv_get()

int wired_h3reqdrive_recv_get ( wired_span stream_data,
wired_mspan scratch,
wired_h3reqdrive_req * r )

RFC 9114 4.1, RFC 9204 4.5: decode a STREAM frame carrying a request: recover :method, :scheme, :authority and :path from the leading HEADERS frame's QPACK field section.

Literal values are copied into scratch. A trailing DATA frame (POST/PUT/PATCH body) is viewed in place via r->body / r->body_len; bodyless requests leave body_len 0.

Parameters
stream_datathe STREAM frame payload carrying the request
scratchcaller-supplied buffer backing r's literal values; the caller keeps it alive while r is in use
rreceives the recovered pseudo-headers and body view
Returns
1 on success, 0 on a malformed frame or field section.

◆ wired_h3reqdrive_recv_get_dyn()

int wired_h3reqdrive_recv_get_dyn ( wired_span stream_data,
wired_mspan scratch,
const qpack_dyn * dyn,
wired_h3reqdrive_req * r )

Same as wired_h3reqdrive_recv_get, but also resolves dynamic-table references (RFC 9204 4.5.2/4.5.3 Indexed Field Line / Indexed Field Line with Post-Base Index) against dyn – the connection's QPACK dynamic table (0 behaves exactly like wired_h3reqdrive_recv_get: every dynamic reference then simply fails to resolve).

Parameters
stream_datathe STREAM frame payload carrying the request
scratchcaller-supplied buffer backing r's literal values; the caller keeps it alive while r is in use
dynthe connection's dynamic table, or 0 if none is tracked
rreceives the recovered pseudo-headers and body view
Returns
1 on success, 0 on a malformed frame, field section, or an unresolvable/invalid dynamic-table reference (RFC 9204 4.5.1.2).

◆ wired_h3reqdrive_send_get()

int wired_h3reqdrive_send_get ( u64 stream_id,
const wired_h3reqdrive_get_in * in,
wired_obuf * out )

RFC 9114 4.1 / 4.3.1, RFC 9204 4.5: drive an HTTP/3 GET request end to end: QPACK-encode the request pseudo-headers (h3reqenc), wrap them in a HEADERS frame and a QUIC STREAM frame (h3conn).

Parameters
stream_idthe request stream id to write in the STREAM frame
inthe :path and :authority values
outreceives the encoded STREAM frame
Returns
1 with out->len set, 0 on overflow.

◆ wired_h3reqdrive_send_method()

int wired_h3reqdrive_send_method ( u64 stream_id,
const wired_h3reqdrive_send_in * in,
wired_obuf * out )

RFC 9114 4.1 / 4.3.1, RFC 9204 4.5: drive an arbitrary-method HTTP/3 request end to end: QPACK-encode the request pseudo-headers with the given :method, append a DATA frame when in->body is non-empty, and wrap in a STREAM frame.

Parameters
stream_idthe request stream id to write in the STREAM frame
inthe request line (method/path/authority) and the optional body
outreceives the encoded STREAM frame
Returns
1 with out->len set, 0 on overflow.

◆ wired_http_req_header()

int wired_http_req_header ( const wired_h3reqdrive_req * req,
wired_span name,
wired_span * out )

RFC 9114 4.2: find a regular request header by name.

Field names are lowercase on the wire, so the match is exact (case-sensitive). cookie returns the crumbs joined with "; " (RFC 9114 4.2.1); other duplicates return the first. Only the first WIRED_H3REQDRIVE_MAX_HDRS other regular headers are searched.

Parameters
reqthe decoded request
namethe lowercase field name
outreceives a view of the value, valid as long as req's views
Returns
1 if found, 0 if not.