Expand description
Proxy-aware HTTP clients with Go net/http semantics, shared by every executor (helps/proxy_helpers.go, sdk/proxyutil, net/http client behaviour; M4-0029).
Proxy: the effective proxy for a request (credential, thenrequests.proxy-url), parsed likeproxyutil.Parse.GoClients: clients keyed by effective proxy in a bounded 64-entry LRU, with Go’s standard-transport proxy rules (empty inherits environment proxies,directandnonebypass them, an unusable URL falls back to the default transport).sendandGoHeaders: one exchange the wayhttp.Client.Doperforms it: HTTP/1.1 header line order, custom Host, manual redirects with Referer and credential stripping, and transparent gzip only when Go would have asked for it.lines:bufio.Scannerline semantics for event streams.
Claude’s first-party Node/OpenSSL profile lives in tls.rs; it uses Proxy and
Hooks from here so both kinds of client share proxy and test routing.
ponytail: no request-scoped proxy override (Go RequestProxyURL / opts.ProxyURL);
ExecRequest carries none. Add a field to the execution envelope when a route needs it.
Structs§
- GoClients
- Go standard-transport clients keyed by effective proxy, most recently used first.
- GoHeaders
- Headers in the order Go’s HTTP/1.1 client writes them: Host, User-Agent (Go’s default when unset), Content-Length, the remaining request headers sorted by key with their values in order, then the transport’s Accept-Encoding.
- Hooks
- Test-only routing: extra trust roots replace the default store, and resolve
overrides pin logical hosts to local addresses while URL, Host and SNI stay
unchanged. Production uses
Hooks::default. - RawUpstream
Upstreamwith the transport’s raw body errors and the response’s protocol version (Go’s response reader keeps framing headers by version).- Route
- How one request hop is sent: its client, and an exact header order for Claude’s
native transport (
Noneis Go net/http’s order). Go’shttp.Clientpicks the round tripper per hop, so a redirect can change both. - Upstream
- A response with Go net/http semantics: the body is decoded only for gzip the transport requested itself, and is never framed or buffered here.
Enums§
- Proxy
- Effective proxy for one request (
effectiveProxyURL+proxyutil.Parse). - Send
Error - Why
send_request_rawfailed: the transport’s own error (which may name the URL, so callers decide what to show), a locally generated one, orTimeout: the deadline passed before a hop was sent, so nothing was sent, and callers report it as they report the transport’s own timeout.urlis the URL Go’s client names in its*url.Error: the failing hop (the caller’s URL as written for the first request), or the rejectedLocationwhen the redirect limit is hit.
Constants§
- MAX_
ERROR_ BODY - Largest error body kept from an upstream rejection.
Functions§
- canonical_
header - Go
textproto.CanonicalMIMEHeaderKey. - default_
client - A plain client whose redirects are followed by
send, not by wreq, with Go’s environment proxy rules. - go_
target - The request Go sends for
url: its scheme and authority as written, thenURL.RequestURI().Nonewhere Go fails (no host, an opaque URL included:http::Urineeds one too) or wreq would not send that: a host Go escapes or IDNA-encodes on the way out (a percent escape, which includes an IPv6 zone, or a non-ASCII byte), or a targethttp::Uridoes not carry as written (given a string, wreq would re-parse and normalize it). - lines
bufio.ScannerwithScanLinesandBuffer(nil, max): one item per line without its\n, a trailing\rdropped, the final unterminated line included, andbufio.ErrTooLongwhen no newline falls withinmaxbytes of a line’s start (the scanner’s buffer never holds more). An I/O error ends the stream after the line buffered before it, asScanreturns that last token before reportingErr.- read_
all io.ReadAllup tolimitbytes; withlossy, a read error keeps what arrived (Go’s error paths ignore it).- redact
proxyutil.Redact: a proxy URL safe for logs (no user info).- request
sendfor any method:http.NewRequest(method, url, body)thenClient.Do, with Go’s redirect rules for that method (a GET follows 301-303 and 307/308 as a GET).Noneis Go’s nil body.- request_
once requestwithout following redirects: a client whoseCheckRedirectreturnshttp.ErrUseLastResponsehands back the first answer, 3xx included. Untimed: it reports no stages (Antigravity’s grounding redirects).- send
- POSTs
bodythe way Go’shttp.Client.Dodoes, following redirects itself: at most ten requests, 301/302/303 turn a POST into a body-less GET, 307/308 resend the body, the initial headers are copied to every hop (credentials only within the original domain), a custom Host survives only relative redirects, and the previous URL becomesReferer.timeoutbounds the exchange. - send_
request send_routedfor any method.Noneis Go’s nil body: no body and no Content-Length (managementapi-call).- send_
request_ raw send_requestwithout error sanitising, for callers that report Go’s own error text (the plugin host’shost.http.*).- send_
routed sendwith the client and header order chosen per hop. Withtiming, the exchange reports its stages to the attempt’s usage record (UpstreamStage).- send_
scanned sendfor a response body the caller reads line by line: a body cut short fails with Go’sunexpected EOF(RawUpstream::scanned).
Type Aliases§
- Shared
GoClients - Shared handle for executors: Go clients plus the hooks used to build them.