I/O Context API ​
httpx owns one std.Io.Threaded per top-level client, server, or pool and shares it across sockets, TLS, and protocol I/O. The helper lives in src/common/io.zig.
IoContext ​
init(allocator)— allocate and initialize astd.Io.Threaded, returning anIoContextdeinit()— shut down the threaded backend and release itio— thestd.Iovalue passed to socket, TLS, and timing APIsthreaded— the owned*std.Io.Threadedallocator— the allocator used for the context itself
zig
var ctx = try httpx.IoContext.init(allocator);
defer ctx.deinit();
const io = ctx.io;Create one context for the lifetime of a Client, Server, or Pool; do not initialize a new IoContext per request or per connection. deinit() must run only after all operations using ctx.io have finished.
Root-level aliases: httpx.IoContext and httpx.ioCtx.
Time Helpers ​
httpx.clock wraps the std.Io clock:
millisNow(io)— milliseconds since the Unix epoch (i64)monotonicMillis(io)— monotonic milliseconds (i64)sleepMillis(io, ms)— sleep on the suppliedstd.Io(returnsvoid)
zig
httpx.clock.sleepMillis(ctx.io, 10);URI and Percent Encoding ​
httpx.uri provides RFC 3986 URI parsing and percent-encoding helpers:
parse(input)— parse into aUriwhose fields referenceinputUri.authority(buf)— formathost[:port], with IPv6 bracketsUri.effectivePort()/defaultPort(scheme)— resolve the default service portpercentDecode(buf, input)— decode into a caller buffer; malformed escapes are copied verbatimpercentEncode(buf, input)— encode into a caller buffer, keeping RFC 3986 unreserved bytespercentEncodeAlloc(allocator, input)— encode into an owned slicehasPathTraversal(decodedPath)— reject./.., NUL, and drive/UNC prefixes
zig
var buf: [64]u8 = undefined;
const decoded = try httpx.uri.percentDecode(&buf, "hello%20world");
const encoded = try httpx.uri.percentEncodeAlloc(allocator, "hello world");
defer allocator.free(encoded);For Base64 and hexadecimal conversion, use std.base64 and std.fmt directly; httpx does not export wrapper types for them.
