HttpHeader
Description
A single Key: Value HTTP header. key and value are both Str objects that own their backing storage through their stored allocator. When kept inside a Vec(HttpHeader), the deep-copy callbacks installed via HttpHeaderInit handle duplication and cleanup automatically.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Http.h:42:
Str key;
Str value;
} HttpHeader;
///
- In
Http.h:56:
#define HttpHeaderInit(...) OVERLOAD(HttpHeaderInit, __VA_ARGS__)
#define HttpHeaderInit_0() HttpHeaderInit_1(MisraScope)
#define HttpHeaderInit_1(alloc_ptr) ((HttpHeader) {.key = StrInit_1(alloc_ptr), .value = StrInit_1(alloc_ptr)})
typedef Vec(HttpHeader) HttpHeaders;- In
Http.h:58:
#define HttpHeaderInit_1(alloc_ptr) ((HttpHeader) {.key = StrInit_1(alloc_ptr), .value = StrInit_1(alloc_ptr)})
typedef Vec(HttpHeader) HttpHeaders;
///
- In
Http.h:69:
/// TAGS: Http, Deinit, Header, Init
///
void HttpHeaderDeinit(HttpHeader *header);
///
- In
Http.h:96:
/// TAGS: Http, Find, Header
///
HttpHeader *http_headers_find_zstr(HttpHeaders *headers, Zstr key);
HttpHeader *http_headers_find_str(HttpHeaders *headers, const Str *key);
#define HttpHeadersFind(headers, key) \- In
Http.h:97:
///
HttpHeader *http_headers_find_zstr(HttpHeaders *headers, Zstr key);
HttpHeader *http_headers_find_str(HttpHeaders *headers, const Str *key);
#define HttpHeadersFind(headers, key) \
_Generic((key), Str *: http_headers_find_str, Zstr: http_headers_find_zstr, char *: http_headers_find_zstr)( \- In
Http.c:19:
// ---------------------------------------------------------------------------
void HttpHeaderDeinit(HttpHeader *header) {
if (!header) {
LOG_FATAL("invalid arguments");- In
Http.c:30:
void http_header_deinit(void *header_ptr, const Allocator *alloc) {
(void)alloc; // each Str carries its own allocator handle
HttpHeader *header = (HttpHeader *)header_ptr;
StrDeinit(&header->key);
StrDeinit(&header->value);- In
Http.c:40:
LOG_FATAL("invalid arguments");
}
HttpHeader *dst = (HttpHeader *)dst_ptr;
const HttpHeader *src = (const HttpHeader *)src_ptr;- In
Http.c:41:
}
HttpHeader *dst = (HttpHeader *)dst_ptr;
const HttpHeader *src = (const HttpHeader *)src_ptr;
dst->key = StrInit((Allocator *)alloc);- In
Http.c:58:
}
HttpHeader *http_headers_find_zstr(HttpHeaders *headers, Zstr key) {
if (!headers || !key) {
LOG_FATAL("invalid arguments");- In
Http.c:70:
}
HttpHeader *http_headers_find_str(HttpHeaders *headers, const Str *key) {
if (!headers || !key) {
LOG_FATAL("invalid arguments");- In
Http.c:159:
}
HttpHeader hh = HttpHeaderInit(alloc);
StrReadFmt(cursor, "{}: {}\r\n", hh.key, hh.value);
if (cursor == line_start) {- In
Http.Leak.c:43:
HttpHeaders headers = VecInitWithDeepCopy(http_header_init_copy, http_header_deinit, adbg);
HttpHeader hh = HttpHeaderInit(adbg);
StrAppendFmt(&hh.key, "X-A-Reasonably-Long-Header-Key-Name");
StrAppendFmt(&hh.value, "a-reasonably-long-header-value-string");- In
Http.c:29:
(ZstrCompare(next, "body-bytes") == 0);
HttpHeader *host = HttpHeadersFind(&req.headers, "Host");
ok = ok && host && ZstrCompare(StrBegin(&host->value), "example.com") == 0;
Last updated on