Utilities API ​
Common utilities for buffer management and encoding.
Shared Helpers ​
httpx.common provides reusable helpers used across client/server/core modules.
queryValue(query, key): Get a query parameter value from a raw query string.parseSetCookiePair(set_cookie): Parse the firstname=valuepair from aSet-Cookieheader value.cookieValue(cookie_header, name): Read a cookie value from a requestCookieheader.buildSetCookieHeader(allocator, name, value, options): Build aSet-Cookieheader value with RFC 6265 style attributes.mimeTypeFromPath(path): Resolve a best-effort MIME type from file extension for static/file responses.CookieOptions: Cookie attributes (Path,Domain,Max-Age,SameSite,Secure,HttpOnly).SameSite: Enum valueslax,strict,none.
Root-level aliases are also available:
httpx.queryValue(...)httpx.parseQueryValue(...)httpx.parseSetCookiePair(...)httpx.parseCookiePair(...)httpx.CookieOptionshttpx.SameSite
Protocol utility aliases are also available at root-level:
httpx.encodeVarInt(...)httpx.decodeVarInt(...)
Compatibility note:
httpx.utilsremains available as an alias tohttpx.common.
Buffers ​
Buffer ​
A dynamic, growable byte buffer.
zig
const buf = try Buffer.init(allocator, 1024);
defer buf.deinit();
try buf.append("Hello");append(bytes: []const u8) !voidtoOwnedSlice() ![]u8clear()
RingBuffer ​
Circular buffer optimized for streaming data.
zig
var ring = try RingBuffer.init(allocator, 4096);writeBytes(bytes: []const u8) !usizereadBytes(buffer: []u8) usizegetAvailable() usizegetFreeSpace() usize
FixedBuffer ​
Stack-allocated fixed-size buffer.
zig
var buf = FixedBuffer(64){};Encoding ​
Base64 ​
Base64 encoding (RFC 4648) with support for standard and URL-safe alphabets.
encode(allocator: Allocator, data: []const u8) ![]u8decode(allocator: Allocator, data: []const u8) ![]u8encodeUrl(allocator: Allocator, data: []const u8) ![]u8
Hex ​
Hexadecimal encoding/decoding.
encode(allocator: Allocator, data: []const u8) ![]u8decode(allocator: Allocator, data: []const u8) ![]u8
PercentEncoding ​
URL encoding/decoding (RFC 3986).
encode(allocator: Allocator, input: []const u8) ![]u8decode(allocator: Allocator, input: []const u8) ![]u8
JSON ​
JsonBuilder ​
Fluent builder for constructing JSON strings efficiently.
zig
var jb = JsonBuilder.init(allocator);
defer jb.deinit();
try jb.beginObject();
try jb.key("name");
try jb.string("John");
try jb.endObject();beginObject() !voidendObject() !voidbeginArray() !voidendArray() !voidkey(name: []const u8) !voidstring(val: []const u8) !voidnumber(val: anytype) !voidboolean(val: bool) !voidnullValue() !void
