Examples ​
This section contains practical httpx.zig demo programs for client, server, middleware, streaming, and protocol features.
How to Use ​
- Open an example page.
- Review the
Demo Programsnippet. - Run the matching command from the
Runsection. - Verify behavior with the checklist.
For non-host targets, compile (without running) by adding -Dtarget=...:
bash
zig build example-tcp_local -Dtarget=x86_64-linux
zig build example-http3_example -Dtarget=aarch64-macosAvailable Examples ​
- Simple Get: Basic GET request and response handling.
- Simple Get Deserialize: Parse JSON into typed structs.
- Post JSON: Send JSON payloads with POST.
- Custom Headers: Attach auth and custom metadata headers.
- Concurrent Requests: Execute multiple requests in parallel.
- Connection Pool: Reuse pooled connections efficiently.
- Interceptors: Apply request and response interceptors.
- Cookies Demo: Manage cookie jar values in client flows.
- Simplified API Aliases: Use short top-level helper APIs.
- Simple Server: Start a minimal HTTP server.
- Router Example: Route params and grouped endpoints.
- Middleware Example: Chain middleware with shared behavior.
- Streaming: Stream data responses.
- Static Files: Serve assets with content types.
- Multi Page Website: Serve multiple HTML pages.
- HTTP/2 Example: HTTP/2 framing and stream primitives.
- HTTP/2 Client Runtime: End-to-end high-level HTTP/2 client request against a local loopback server.
- HTTP/2 Server Runtime: End-to-end high-level HTTP/2 server route consumed by a local HTTP/2 client.
- HTTP/3 Example: HTTP/3, QPACK, and QUIC primitives.
- HTTP/3 Client Runtime: End-to-end high-level HTTP/3 client request against a local UDP loopback server.
- HTTP/3 Server Runtime: End-to-end high-level HTTP/3 server route consumed by a local HTTP/3 client over UDP.
- TCP Local: Local TCP listener/client round trip.
- UDP Local: Local UDP transport demo.
