Fields
allocator: Allocator,
list: HeaderList = .{ },
index: HeaderIndex = .{ },
owned: bool = true,
When this is false, names and values will not be duplicated. Use with caution.
Functions
fn append(headers: *Headers, name: []const u8, value: []const u8) !void
Appends a header to the list. Both name and value are copied.
fn clearAndFree(headers: *Headers) void
Clears and frees the underlying data structures. Frees names and values if they…
Clears and frees the underlying data structures. Frees names and values if they are owned.
fn clearRetainingCapacity(headers: *Headers) void
Clears the underlying data structures while retaining their capacities. Frees n…
Clears the underlying data structures while retaining their capacities. Frees names and values if they are owned.
fn firstIndexOf(headers: Headers, name: []const u8) ?usize
Returns the index of the first occurrence of a header with the given name.
fn format(headers: Headers, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: anytype) !void
Writes the headers to the given stream.
fn formatCommaSeparated(headers: Headers, name: []const u8, out_stream: anytype) !void
Writes all of the headers with the given name to the given stream, separated by …
Writes all of the headers with the given name to the given stream, separated by commas.
This is useful for headers like
Set-Cookie
which can have multiple values. RFC 9110, Section 5.2fn getEntries(headers: Headers, allocator: Allocator, name: []const u8) !?[]const Field
Returns a slice containing each header with the given name. The caller owns the…
Returns a slice containing each header with the given name. The caller owns the returned slice, but NOT the values in the slice.
fn getFirstEntry(headers: Headers, name: []const u8) ?Field
Returns the entry of the first occurrence of a header with the given name.
fn getFirstValue(headers: Headers, name: []const u8) ?[]const u8
Returns the value in the entry of the first occurrence of a header with the give…
Returns the value in the entry of the first occurrence of a header with the given name.
fn getIndices(headers: Headers, name: []const u8) ?[]const usize
Returns a list of indices containing headers with the given name.
fn getValues(headers: Headers, allocator: Allocator, name: []const u8) !?[]const []const u8
Returns a slice containing the value of each header with the given name. The ca…
Returns a slice containing the value of each header with the given name. The caller owns the returned slice, but NOT the values in the slice.