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 vec’s deep-copy callbacks (http_header_init_copy / http_header_deinit) handle duplication and cleanup automatically.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Http.c:26:
(ZstrCompare(next, "body-bytes") == 0);
HttpHeader *host = HttpHeadersFind(&req.headers, "Host");
ok = ok && host && ZstrCompare(host->value.data, "example.com") == 0;- In
Http.c:18:
// ---------------------------------------------------------------------------
void HttpHeaderDeinit(HttpHeader *header) {
if (!header) {
LOG_FATAL("invalid arguments");- In
Http.c:32:
return;
}
HttpHeader *header = (HttpHeader *)header_ptr;
StrDeinit(&header->key);
StrDeinit(&header->value);- In
Http.c:42:
LOG_FATAL("invalid arguments");
}
HttpHeader *dst = (HttpHeader *)dst_ptr;
const HttpHeader *src = (const HttpHeader *)src_ptr;- In
Http.c:43:
}
HttpHeader *dst = (HttpHeader *)dst_ptr;
const HttpHeader *src = (const HttpHeader *)src_ptr;
dst->key = StrInit((Allocator *)alloc);- In
Http.c:60:
}
HttpHeader *HttpHeadersFind(HttpHeaders *headers, const char *key) {
if (!headers || !key) {
LOG_ERROR("invalid arguments");- In
Http.c:143:
}
HttpHeader hh = HttpHeaderInit(alloc);
StrReadFmt(cursor, "{}: {}\r\n", hh.key, hh.value);
if (cursor == line_start) {- In
Http.h:39:
Str key;
Str value;
} HttpHeader;
///
- In
Http.h:47:
#define HttpHeaderInit(...) MISRA_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:49:
#define HttpHeaderInit_1(alloc_ptr) ((HttpHeader) {.key = StrInit_1(alloc_ptr), .value = StrInit_1(alloc_ptr)})
typedef Vec(HttpHeader) HttpHeaders;
///
- In
Http.h:55:
/// `header->key` and `header->value`, then zeros the struct.
///
void HttpHeaderDeinit(HttpHeader *header);
///
- In
Http.h:76:
/// FAILURE : NULL if no header matches.
///
HttpHeader *HttpHeadersFind(HttpHeaders *headers, const char *key);
typedef enum HttpResponseCode {
Last updated on