std1.0.0-beta-7 SafeC docs

std :: http::headers

Struct std::HttpHeaders

#include <std/http/headers.h> source

struct HttpHeaders {
    struct Vec<struct HttpHeaderField> fields;
}

Fields

§struct Vec<struct HttpHeaderField> fieldssource

Methods

§static struct HttpHeaders new()source · definition
§static struct HttpHeaders parse(const &char raw)source · definition

Parses a raw "Key: value" block (lines end in "\r\n" or "\n"; a line without ':' is skipped; leading/trailing blanks are trimmed; an obsolete folded continuation line — leading space/tab — is joined onto the previous value with one space).

§unsigned long length() constsource · definition
§const ?&char get(const &char name) constsource · definition

The first value for 'name' (any case), or null. The reference aliases this object's storage: valid until the next mutation/free().

§const &char get_or(const &char name, const &char fallback) constsource · definition
§unsigned long count(const &char name) constsource · definition

How many fields have this name, and the n-th one's value.

§const ?&char get_nth(const &char name, unsigned long n) constsource · definition
§struct String get_joined(const &char name) constsource · definition

Every value for 'name' joined with ", " (the RFC 9110 §5.3 combination; empty String if absent). Not meaningful for Set-Cookie.

§int has(const &char name) constsource · definition
§int contains_token(const &char name, const &char token) constsource · definition

1 if 'name' holds a comma-separated list containing 'token' (case- insensitive), e.g. contains_token("Connection", "upgrade").

§const ?&char name_at(unsigned long i) constsource · definition

i-th field in order (null past the end).

§const ?&char value_at(unsigned long i) constsource · definition
§void append(const &char name, const &char value)source · definition

Adds a field at the end, keeping any existing ones with this name.

§void set(const &char name, const &char value)source · definition

Replaces the first field with this name (keeping its position) and drops the others; appends one if there was none.

§unsigned long remove(const &char name)source · definition

Removes every field with this name; returns how many there were.

§void clear()source · definition
§void write_to(&String out) constsource · definition

"Name: value\r\n" per field (CRLF after every line, including the last), appended to 'out' — the shape a request/response header block is sent in.

§struct String to_raw() constsource · definition

The raw block form HttpRequest/HttpResponse store: lines CRLF- separated, no trailing CRLF.

§struct HttpHeaders clone() constsource · definition
§void drop()source · definition
§void free() consumesource · definition

= drop()