Documentation
¶
Overview ¶
Package bulkhttp is the multiplexing transport for request-heavy work aimed at one origin at a time: wordlist discovery and the fuzz primitive. The module scanner does not use it; it stays on HTTP/1.1 with its 1:1 request-to-connection mapping (smuggling, header-order, raw and timing modules depend on that).
A Transport picks one protocol per origin and keeps it, so every response a caller compares (a soft-404 fingerprint, a fuzz baseline) came over the same protocol:
- HTTP/3, when the mode allows it, the origin is https, no proxy applies, and a direct QUIC handshake to the origin's port succeeds and delivers the server's SETTINGS within ProbeTimeout. The handshake is the only probe; it sends no HTTP request.
- otherwise TCP: HTTP/2 when TLS ALPN selects h2, else HTTP/1.1. Cleartext http:// stays HTTP/1.1 (no h2c), and a proxied origin negotiates through its CONNECT tunnel like any client.
The choice is made before the origin's first request is sent. An HTTP/3 origin whose connections keep failing is demoted to TCP for the rest of the Transport's life (logged once), because a scan that stops sending is worse than one whose protocol changed.
A request whose meaning is HTTP/1.1-only - a connection-specific header that HTTP/2 and HTTP/3 forbid, their encoders silently drop, and whose loss changes what the server sees (see RequiresHTTP1) - is sent on a separate HTTP/1.1 transport whatever the origin's protocol.
HTTP/3 connections are owned by the Transport: each is dialed on its own UDP socket, admitted up to StreamsPerConn concurrent requests, and retired by identity when it dies, so a late error from a dead connection can never evict its healthy replacement. More connections are opened only when every live one is full, up to MaxH3Conns per origin.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RequiresHTTP1 ¶
RequiresHTTP1 reports why a request with header h must be sent as HTTP/1.1, or "" when any protocol carries it faithfully. HTTP/2 and HTTP/3 forbid connection-specific header fields (RFC 9113 §8.2.2, RFC 9114 §4.2) and Go's and quic-go's encoders silently drop them, so only the ones whose loss changes what the server sees force HTTP/1.1:
- Upgrade (a protocol switch: WebSocket, h2c);
- Transfer-Encoding left in the header map (net/http lifts chunked into Request.TransferEncoding; anything still here is deliberate);
- TE other than "trailers";
- Connection naming anything but keep-alive/close: it nominates headers for a proxy to strip, the hop-by-hop abuse a request may be probing.
Connection: keep-alive/close, Keep-Alive and Proxy-Connection are pure HTTP/1.x connection management - every browser and proxy drops them when it speaks HTTP/2 - and a captured request almost always carries one, so they do not hold a request on HTTP/1.1.
h's keys must be canonical, as net/http builds them.
Types ¶
type Config ¶
type Config struct {
// Base is the HTTP/1.1 transport template. Its Proxy, DialContext,
// TLSClientConfig, timeouts and idle-pool sizes carry over to every
// protocol. It is cloned, never used or mutated.
Base *http.Transport
// Mode is the protocol policy; empty is ModeAuto.
Mode Mode
// ProbeTimeout bounds the HTTP/3 proof (QUIC handshake plus the server's
// SETTINGS). Default 2s.
ProbeTimeout time.Duration
// StreamsPerConn caps concurrent requests on one HTTP/3 connection.
// Default 100, the common server MAX_STREAMS; a peer that allows fewer
// simply makes the excess wait inside quic-go.
StreamsPerConn int
// MaxH3Conns caps HTTP/3 connections per origin. Default 8.
MaxH3Conns int
// ResolveAddr, when set, maps a "host:port" to the "ip:port" to dial for
// HTTP/3 (curl --resolve). The TCP side applies its own mapping in
// Base.DialContext.
ResolveAddr func(hostPort string) string
}
Config configures a Transport.
type Mode ¶
type Mode string
Mode selects which protocols a Transport may use.
const ( // ModeAuto prefers HTTP/3, then HTTP/2, then HTTP/1.1, per origin. ModeAuto Mode = "auto" // ModeHTTP1 never negotiates anything but HTTP/1.1. ModeHTTP1 Mode = "http1" // ModeHTTP2 stays on TCP and uses HTTP/2 wherever ALPN selects it. ModeHTTP2 Mode = "http2" // ModeHTTP3 requires HTTP/3: a request to an origin that cannot speak it // fails instead of falling back. ModeHTTP3 Mode = "http3" )
type Protocol ¶
type Protocol string
Protocol is the HTTP version an origin's requests use.
func (Protocol) Multiplexed ¶
Multiplexed reports whether p carries concurrent requests on one connection.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is an http.RoundTripper that multiplexes requests over HTTP/2 or HTTP/3 where the origin supports it. See the package documentation.
func (*Transport) Close ¶
func (t *Transport) Close()
Close closes every connection. Requests in flight fail; later requests are refused.
func (*Transport) CloseIdleConnections ¶
func (t *Transport) CloseIdleConnections()
CloseIdleConnections closes idle TCP connections and HTTP/3 connections with no request in flight.
func (*Transport) Prepare ¶
Prepare decides u's protocol without sending an HTTP request and returns it: the HTTP/3 probe when eligible, else a TLS handshake that reads the ALPN result (direct https origins only). A proxied TCP origin reports ProtoUnknown until its first response.