httpx

package
v1.40.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package httpx is the SINGLE egress chokepoint for qmax-code. Every outbound HTTP request in the codebase must be built with NewRequest and sent through a client from NewClient, so that the Exposure Receipt records it — destination, category, byte size, and content SHA-256, never content itself.

The static guard in guard_test.go enforces that no other package constructs HTTP clients/requests or imports a third-party HTTP library, making an un-receipted egress path impossible to merge — the load-bearing half of the "Receipts, not promises" guarantee.

Quality commitments enforced here:

  • Stream, don't buffer: request bodies are hashed by a streaming reader as the transport sends them, so a multi-MB prompt (inlined files, images) is never doubled in memory (io.ReadAll on the request body is forbidden).
  • Never silent: every attempt is recorded, including transport errors. The receipt module routes entries to the process-global session receipt when no receipt-bearing context is present, so even a plain context.Background request is accounted for.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialWebSocket

func DialWebSocket(ctx context.Context, url string, opts *websocket.DialOptions) (*websocket.Conn, *http.Response, error)

DialWebSocket performs a WebSocket handshake through the recording HTTP client. The WebSocket protocol itself uses the upgraded connection, while the destination and handshake egress are captured in the session receipt.

func NewClient

func NewClient(timeout time.Duration) *http.Client

NewClient returns an *http.Client whose Transport records every request into the active Exposure Receipt. Timeout semantics are unchanged from a plain &http.Client{Timeout: timeout}.

func NewRequest

func NewRequest(ctx context.Context, method, url string, body io.Reader) (*http.Request, error)

NewRequest builds an *http.Request bound to ctx. It is the only sanctioned way to construct an outbound request outside this package: callers that need to set custom headers or stream the response (LLM SSE) use NewRequest + NewClient.Do rather than a raw http.NewRequest, which the egress guard forbids.

Pass context.Background() when no request-scoped context is available; the receipt still routes to the process-global session run.

func WithCategory

func WithCategory(ctx context.Context, category string) context.Context

WithCategory annotates ctx with an explicit receipt category. Most HTTP callers rely on exposure.Classify; use this only for protocol handshakes.

func WithModel

func WithModel(ctx context.Context, model string) context.Context

WithModel annotates ctx with the LLM model id for requests built from it. LLM call sites (Anthropic, Cerebras, Ollama) wrap their context with this so the receipt records model attribution; all other traffic omits it.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL