Documentation
ΒΆ
Overview ΒΆ
Package surf provides a comprehensive HTTP client library with advanced features for web scraping, automation, and HTTP/3 support with various browser fingerprinting capabilities.
Index ΒΆ
- Constants
- type AckECNMode
- type AckReorderingMode
- type AlternativeServiceBackoff
- type Body
- func (b *Body) Bytes() g.Result[g.Bytes]
- func (b *Body) Close() error
- func (b *Body) Contains(pattern any) bool
- func (b *Body) Dump(filename g.String) error
- func (b *Body) JSON(data any) error
- func (b *Body) Limit(limit int64) *Body
- func (b *Body) SSE(fn func(event *sse.Event) bool) error
- func (b *Body) Stream() *StreamReader
- func (b *Body) String() g.Result[g.String]
- func (b *Body) UTF8() g.Result[g.String]
- func (b *Body) WithContext(ctx context.Context) *Body
- func (b *Body) XML(data any) error
- type Builder
- func (b *Builder) AddCookies(cookies ...*http.Cookie) *Builder
- func (b *Builder) AddHeaders(headers ...any) *Builder
- func (b *Builder) BasicAuth(authentication g.String) *Builder
- func (b *Builder) BearerAuth(authentication g.String) *Builder
- func (b *Builder) Boundary(boundary func() g.String) *Builder
- func (b *Builder) Build() g.Result[*Client]
- func (b *Builder) CacheBody() *Builder
- func (b *Builder) CertificateIntermediates(pool *x509.CertPool) *Builder
- func (b *Builder) ClientHints() *ClientHints
- func (b *Builder) ContentType(contentType g.String) *Builder
- func (b *Builder) DNS(dns g.String) *Builder
- func (b *Builder) DNSOverTLS() *DNSOverTLS
- func (b *Builder) DisableCompression() *Builder
- func (b *Builder) DisableKeepAlive() *Builder
- func (b *Builder) FollowOnlyHostRedirects() *Builder
- func (b *Builder) ForceHTTP1() *Builder
- func (b *Builder) ForceHTTP2() *Builder
- func (b *Builder) ForceHTTP3() *Builder
- func (b *Builder) ForwardHeadersOnRedirect() *Builder
- func (b *Builder) GetRemoteAddress() *Builder
- func (b *Builder) H2C() *Builder
- func (b *Builder) HTTP1Settings() *HTTP1Settings
- func (b *Builder) HTTP2Settings() *HTTP2Settings
- func (b *Builder) HTTP3Settings() *HTTP3Settings
- func (b *Builder) Impersonate() *Impersonate
- func (b *Builder) InterfaceAddr(address g.String) *Builder
- func (b *Builder) JA() *JA
- func (b *Builder) MaxRedirects(maxRedirects int) *Builder
- func (b *Builder) NetworkSettings() *NetworkSettings
- func (b *Builder) NotFollowRedirects() *Builder
- func (b *Builder) Proxy(proxy g.String) *Builder
- func (b *Builder) QUICSettings() *QUICSettings
- func (b *Builder) RedirectPolicy(fn func(*http.Request, []*http.Request) error) *Builder
- func (b *Builder) Retry(retryMax int, retryWait time.Duration, codes ...int) *Builder
- func (b *Builder) SecureTLS() *Builder
- func (b *Builder) Session() *Builder
- func (b *Builder) SessionCache() *SessionCache
- func (b *Builder) SetHeaders(headers ...any) *Builder
- func (b Builder) String() string
- func (b *Builder) TLSConfig(config *tls.Config) *Builder
- func (b *Builder) Timeout(timeout time.Duration) *Builder
- func (b *Builder) UnixSocket(address g.String) *Builder
- func (b *Builder) UserAgent(userAgent any) *Builder
- func (b *Builder) WebSocketGuard() *Builder
- func (b *Builder) With(middleware any, priority ...int) *Builder
- func (b *Builder) WithContext(ctx context.Context) *Builder
- type Client
- func (c *Client) Builder() *Builder
- func (c *Client) ClearClientHints()
- func (c *Client) ClientHintNames(rawURL g.String) []string
- func (c *Client) Close() error
- func (c *Client) CloseIdleConnections()
- func (c *Client) Connect(rawURL g.String) *Request
- func (c *Client) Delete(rawURL g.String) *Request
- func (c *Client) Get(rawURL g.String) *Request
- func (c *Client) GetClient() *http.Client
- func (c *Client) GetDialer() *net.Dialer
- func (c *Client) GetTLSConfig() *tls.Config
- func (c *Client) GetTransport() http.RoundTripper
- func (c *Client) Head(rawURL g.String) *Request
- func (c *Client) NetworkChanged(changes ...NetworkChangeInfo)
- func (c *Client) Options(rawURL g.String) *Request
- func (c *Client) Patch(rawURL g.String) *Request
- func (c *Client) Post(rawURL g.String) *Request
- func (c *Client) Put(rawURL g.String) *Request
- func (c *Client) Raw(raw, scheme g.String) *Request
- func (c *Client) Std() *_http.Client
- func (c *Client) Trace(rawURL g.String) *Request
- type ClientHintBrand
- type ClientHints
- func (h *ClientHints) ALPS(value bool) *ClientHints
- func (h *ClientHints) Architecture(value string) *ClientHints
- func (h *ClientHints) Bitness(value string) *ClientHints
- func (h *ClientHints) Capacity(value int) *ClientHints
- func (h *ClientHints) ClearSiteData(value bool) *ClientHints
- func (h *ClientHints) Clock(value func() time.Time) *ClientHints
- func (h *ClientHints) Enabled(value bool) *ClientHints
- func (h *ClientHints) FormFactors(values ...string) *ClientHints
- func (h *ClientHints) FullVersion(value string) *ClientHints
- func (h *ClientHints) FullVersionList(values ...ClientHintBrand) *ClientHints
- func (h *ClientHints) Lifetime(value time.Duration) *ClientHints
- func (h *ClientHints) Model(value string) *ClientHints
- func (h *ClientHints) PlatformVersion(value string) *ClientHints
- func (h *ClientHints) Set() *Builder
- func (h *ClientHints) Value(name, value string) *ClientHints
- func (h *ClientHints) WoW64(value bool) *ClientHints
- type CongestionControlAlgorithm
- type ConnectionRacingInfo
- type ConnectionRacingPolicy
- type CookieJarAdapter
- type Cookies
- type CryptoRange
- type DNSOverTLS
- func (dot *DNSOverTLS) AdGuard() *Builder
- func (dot *DNSOverTLS) AddProvider(serverName g.String, addresses ...g.String) *Builder
- func (dot *DNSOverTLS) Ali() *Builder
- func (dot *DNSOverTLS) CIRAShield() *Builder
- func (dot *DNSOverTLS) Cloudflare() *Builder
- func (dot *DNSOverTLS) Forge() *Builder
- func (dot *DNSOverTLS) Google() *Builder
- func (dot *DNSOverTLS) LibreDNS() *Builder
- func (dot *DNSOverTLS) Quad9() *Builder
- func (dot *DNSOverTLS) Quad101() *Builder
- func (dot *DNSOverTLS) SB() *Builder
- func (dot *DNSOverTLS) Switch() *Builder
- type Debug
- type EarlyRequestPolicy
- type Err101ResponseCode
- type ErrHTTP2Fallback
- type ErrUserAgentType
- type ErrWebSocketUpgrade
- type HPACKHuffmanMode
- type HPACKNameReferencePolicy
- type HPACKRepresentation
- type HTTP1Settings
- type HTTP2ConnectionCloseInfo
- type HTTP2ConnectionCloseOptions
- type HTTP2ReceiveWindowUpdateInfo
- type HTTP2RequestBodyInfo
- type HTTP2RequestBodyOptions
- type HTTP2Settings
- func (h *HTTP2Settings) ChainStreamDependencies(enabled bool) *HTTP2Settings
- func (h *HTTP2Settings) ConnectionClosePolicy(policy func(HTTP2ConnectionCloseInfo) HTTP2ConnectionCloseOptions) *HTTP2Settings
- func (h *HTTP2Settings) ConnectionFlow(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) EnablePush(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) HTTP1RequiredCache(capacity int) *HTTP2Settings
- func (h *HTTP2Settings) HeaderPriority(policy func(http2.PriorityRequest) http2.PriorityParam) *HTTP2Settings
- func (h *HTTP2Settings) HeaderTableSize(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) HealthCheckPayload(payload *[8]byte) *HTTP2Settings
- func (h *HTTP2Settings) HpackDeduplicateTableSizeUpdates(enabled bool) *HTTP2Settings
- func (h *HTTP2Settings) HpackDefaultRepresentation(rep HPACKRepresentation) *HTTP2Settings
- func (h *HTTP2Settings) HpackHuffman(mode HPACKHuffmanMode) *HTTP2Settings
- func (h *HTTP2Settings) HpackIndexingLimit(limit func(tableCapacity uint32) uint32) *HTTP2Settings
- func (h *HTTP2Settings) HpackNameReferencePolicy(policy HPACKNameReferencePolicy) *HTTP2Settings
- func (h *HTTP2Settings) HpackPolicy(policy func(name, value string) HPACKRepresentation) *HTTP2Settings
- func (h *HTTP2Settings) HpackRepresentation(name string, rep HPACKRepresentation) *HTTP2Settings
- func (h *HTTP2Settings) InitialPeerSettings(policy func([]http2.Setting) ([]http2.Setting, error)) *HTTP2Settings
- func (h *HTTP2Settings) InitialStreamID(id uint32) *HTTP2Settings
- func (h *HTTP2Settings) InitialWindowSize(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) MaxConcurrentStreams(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) MaxEncoderHeaderTableSize(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) MaxFrameSize(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) MaxHeaderListSize(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) NoRFC7540Priorities(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) PingTimeout(timeout time.Duration) *HTTP2Settings
- func (h *HTTP2Settings) PriorityFrames(priorityFrames []http2.PriorityFrame) *HTTP2Settings
- func (h *HTTP2Settings) PriorityParam(priorityParam http2.PriorityParam) *HTTP2Settings
- func (h *HTTP2Settings) ReadIdleTimeout(timeout time.Duration) *HTTP2Settings
- func (h *HTTP2Settings) ReceiveWindowUpdatePolicy(policy func(HTTP2ReceiveWindowUpdateInfo) bool) *HTTP2Settings
- func (h *HTTP2Settings) RequestBodyPolicy(policy func(HTTP2RequestBodyInfo) HTTP2RequestBodyOptions) *HTTP2Settings
- func (h *HTTP2Settings) Set() *Builder
- func (h *HTTP2Settings) StreamReceiveWindow(size uint32) *HTTP2Settings
- func (h *HTTP2Settings) WriteBufferSize(size int) *HTTP2Settings
- type HTTP3GreaseFrame
- type HTTP3PriorityUpdater
- type HTTP3RequestBodyReadInfo
- type HTTP3Settings
- func (h *HTTP3Settings) AdditionalSettings(settings g.MapOrd[uint64, uint64]) *HTTP3Settings
- func (h *HTTP3Settings) AltUsed(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) AlternativeServiceBackoff(policy AlternativeServiceBackoff) *HTTP3Settings
- func (h *HTTP3Settings) ClientHandshake(config *quic.ClientHandshake) *HTTP3Settings
- func (h *HTTP3Settings) ClientHelloFactory(factory func() (utls.ClientHelloSpec, error)) *HTTP3Settings
- func (h *HTTP3Settings) ClientHelloSpec(spec *utls.ClientHelloSpec) *HTTP3Settings
- func (h *HTTP3Settings) CoalesceInitialSettings(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) CoalesceRequestHeaders(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) CompactPriorityUpdates(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) ConnectionCoalescing(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) ConnectionIDGenerator(generator quic.ConnectionIDGenerator) *HTTP3Settings
- func (h *HTTP3Settings) ConnectionIDLength(length int) *HTTP3Settings
- func (h *HTTP3Settings) ConnectionPoolPartition(partition func(context.Context, string) string) *HTTP3Settings
- func (h *HTTP3Settings) ConnectionRacing(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) ConnectionRacingPolicy(policy ConnectionRacingPolicy) *HTTP3Settings
- func (h *HTTP3Settings) ControlGreaseFrames(frames ...HTTP3GreaseFrame) *HTTP3Settings
- func (h *HTTP3Settings) ControlGreaseFramesFactory(factory func() ([]HTTP3GreaseFrame, error)) *HTTP3Settings
- func (h *HTTP3Settings) Discovery(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) ECHClientHelloInner(policy utls.ECHClientHelloInnerFunc) *HTTP3Settings
- func (h *HTTP3Settings) EarlyData(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) EarlyDataBackup(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) EarlyDataRestart(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) EarlyRequestPolicy(policy EarlyRequestPolicy) *HTTP3Settings
- func (h *HTTP3Settings) EnableConnectProtocol(num uint64) *HTTP3Settings
- func (h *HTTP3Settings) EnableDatagrams(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) EnableWebtransport(num uint64) *HTTP3Settings
- func (h *HTTP3Settings) ExpireFailedAlternatives(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) FlushEarlySettings(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) Grease() *HTTP3Settings
- func (h *HTTP3Settings) GreaseFactory(factory func() (uint64, uint64, error)) *HTTP3Settings
- func (h *HTTP3Settings) H3Datagram(num uint64) *HTTP3Settings
- func (h *HTTP3Settings) HTTPSRecordsLookup(lookup HTTPSRecordsLookup) *HTTP3Settings
- func (h *HTTP3Settings) HTTPSRecordsWait(policy func(time.Duration) time.Duration) *HTTP3Settings
- func (h *HTTP3Settings) IgnoreIPMatching(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) MaxDataFrameSize(size int) *HTTP3Settings
- func (h *HTTP3Settings) MaxFieldSectionSize(num uint64) *HTTP3Settings
- func (h *HTTP3Settings) MaxResponseHeaderBytes(limit int) *HTTP3Settings
- func (h *HTTP3Settings) OnOrigin(callback func(*quic.Conn, []string)) *HTTP3Settings
- func (h *HTTP3Settings) OnResponseHeaders(callback func(*http.Request, *http.Response) error) *HTTP3Settings
- func (h *HTTP3Settings) OriginFrameLimit(limit int) *HTTP3Settings
- func (h *HTTP3Settings) OriginFrames(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) PriorityUpdates(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) QUICConfig(config *quic.Config) *HTTP3Settings
- func (h *HTTP3Settings) QpackBlockedStreams(num uint64) *HTTP3Settings
- func (h *HTTP3Settings) QpackDrainingFraction(fraction float64) *HTTP3Settings
- func (h *HTTP3Settings) QpackDynamicTable(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) QpackEagerStreamTypes(eager bool) *HTTP3Settings
- func (h *HTTP3Settings) QpackEncoderCapacityRequiresSetting(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) QpackEncoderCapacityTiming(timing QPACKCapacityTiming) *HTTP3Settings
- func (h *HTTP3Settings) QpackEncoderTableCapacity(capacity uint64) *HTTP3Settings
- func (h *HTTP3Settings) QpackEncoderZeroCapacity(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) QpackHuffman(mode QPACKHuffmanMode) *HTTP3Settings
- func (h *HTTP3Settings) QpackIndexing(mode QPACKIndexingMode) *HTTP3Settings
- func (h *HTTP3Settings) QpackIndexingPolicy(policy func(name, value string) bool) *HTTP3Settings
- func (h *HTTP3Settings) QpackLiteralInsertNames(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) QpackMaxTableCapacity(num uint64) *HTTP3Settings
- func (h *HTTP3Settings) QpackMaxTrackedSections(limit uint64) *HTTP3Settings
- func (h *HTTP3Settings) QpackNeverIndex(names ...string) *HTTP3Settings
- func (h *HTTP3Settings) QpackPostBaseReferences(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) QpackResumptionErrorCode(policy func(previous, current uint64) http3.ErrCode) *HTTP3Settings
- func (h *HTTP3Settings) QpackSplitCookies(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) QpackStopOnInsertionFailure(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) QpackStreamOrder(order ...QPACKStreamType) *HTTP3Settings
- func (h *HTTP3Settings) RequestBodyBufferSize(size int) *HTTP3Settings
- func (h *HTTP3Settings) RequestBodyBufferSizePolicy(policy func(int64) int) *HTTP3Settings
- func (h *HTTP3Settings) RequestBodyFirstReadSizePolicy(policy func(HTTP3RequestBodyReadInfo) int) *HTTP3Settings
- func (h *HTTP3Settings) RequestGreaseFrames(frames ...HTTP3GreaseFrame) *HTTP3Settings
- func (h *HTTP3Settings) RequestGreaseFramesFactory(factory func(*http.Request) ([]HTTP3GreaseFrame, error)) *HTTP3Settings
- func (h *HTTP3Settings) Set() *Builder
- func (h *HTTP3Settings) SettingsH3Datagram(num uint64) *HTTP3Settings
- func (h *HTTP3Settings) StreamPriority(urgency int8, incremental bool) *HTTP3Settings
- func (h *HTTP3Settings) TCPFallbackAfterQUICStart(enabled bool) *HTTP3Settings
- func (h *HTTP3Settings) TCPFallbackDelay(delay time.Duration) *HTTP3Settings
- type HTTPSRecord
- type HTTPSRecordsLookup
- type Headers
- type Impersonate
- func (im *Impersonate) Android() *Impersonate
- func (im *Impersonate) Chrome() *Builder
- func (im *Impersonate) Firefox() *Builder
- func (im *Impersonate) IOS() *Impersonate
- func (im *Impersonate) Linux() *Impersonate
- func (im *Impersonate) MacOS() *Impersonate
- func (im *Impersonate) RandomOS() *Impersonate
- func (im *Impersonate) Windows() *Impersonate
- type InitialCryptoLayoutInfo
- type JA
- func (j *JA) Android() *Builder
- func (j *JA) Chrome() *Builder
- func (j *JA) Chrome158() *Builder
- func (j *JA) CloseNotify(enabled bool) *JA
- func (j *JA) DynamicRecordSizing(enabled bool) *JA
- func (j *JA) ECHClientHelloInner(policy utls.ECHClientHelloInnerFunc) *JA
- func (j *JA) Edge() *Builder
- func (j *JA) Edge85() *Builder
- func (j *JA) Edge106() *Builder
- func (j *JA) Firefox() *Builder
- func (j *JA) Firefox55() *Builder
- func (j *JA) Firefox56() *Builder
- func (j *JA) Firefox63() *Builder
- func (j *JA) Firefox65() *Builder
- func (j *JA) Firefox99() *Builder
- func (j *JA) Firefox102() *Builder
- func (j *JA) Firefox105() *Builder
- func (j *JA) Firefox120() *Builder
- func (j *JA) Firefox148() *Builder
- func (j *JA) Firefox160() *Builder
- func (j *JA) IOS() *Builder
- func (j *JA) IOS11() *Builder
- func (j *JA) IOS12() *Builder
- func (j *JA) IOS13() *Builder
- func (j *JA) IOS14() *Builder
- func (j *JA) KeepAlivePolicy(policy func(TCPKeepAliveInfo) TCPKeepAliveOptions) *JA
- func (j *JA) Randomized() *Builder
- func (j *JA) RandomizedALPN() *Builder
- func (j *JA) RandomizedNoALPN() *Builder
- func (j *JA) Safari() *Builder
- func (j *JA) Safari26_3() *Builder
- func (j *JA) SetHelloID(id utls.ClientHelloID) *Builder
- func (j *JA) SetHelloSpec(spec utls.ClientHelloSpec) *Builder
- func (j *JA) ShuffleExtensions() *JA
- type Multipart
- func (m *Multipart) ContentType(ct g.String) *Multipart
- func (m *Multipart) Field(name, value g.String) *Multipart
- func (m *Multipart) File(fieldName g.String, file *fs.File) *Multipart
- func (m *Multipart) FileBytes(fieldName, fileName g.String, data g.Bytes) *Multipart
- func (m *Multipart) FileName(name g.String) *Multipart
- func (m *Multipart) FileReader(fieldName, fileName g.String, reader io.Reader) *Multipart
- func (m *Multipart) FileString(fieldName, fileName, content g.String) *Multipart
- func (m *Multipart) Retry() *Multipart
- type MultipartFile
- type NetworkChangeAction
- type NetworkChangeInfo
- type NetworkChangePolicy
- type NetworkSettings
- func (n *NetworkSettings) Automatic(enabled bool) *NetworkSettings
- func (n *NetworkSettings) CoalescingDelay(delay time.Duration) *NetworkSettings
- func (n *NetworkSettings) Identity(reader func([]netip.Addr) (string, error)) *NetworkSettings
- func (n *NetworkSettings) Policy(policy NetworkChangePolicy) *NetworkSettings
- func (n *NetworkSettings) Set() *Builder
- type PacingAlgorithm
- type PeerAckFrequency
- type PeerAckFrequencyInfo
- type PeerAckFrequencyPolicy
- type PeerPacketInfo
- type PeerPacketRecovery
- type QPACKCapacityTiming
- type QPACKHuffmanMode
- type QPACKIndexingMode
- type QPACKStreamType
- type QUICSettings
- func (q *QUICSettings) AckDecimation(after, threshold uint64) *QUICSettings
- func (q *QUICSettings) AckDelayRTTDivisor(divisor uint32) *QUICSettings
- func (q *QUICSettings) AckECN(mode AckECNMode) *QUICSettings
- func (q *QUICSettings) AckFlushOnPacket(enabled bool) *QUICSettings
- func (q *QUICSettings) AckMissingPacketLimit(packets uint64) *QUICSettings
- func (q *QUICSettings) AckOnlyMaxDataThreshold(threshold int) *QUICSettings
- func (q *QUICSettings) AckOnlyPingThreshold(threshold int) *QUICSettings
- func (q *QUICSettings) AckPacketThreshold(packets uint64) *QUICSettings
- func (q *QUICSettings) AckProbePolicy(policy func(quic.AckProbeInfo) bool) *QUICSettings
- func (q *QUICSettings) AckReordering(mode AckReorderingMode) *QUICSettings
- func (q *QUICSettings) ActiveConnectionIDLimit(limit uint64) *QUICSettings
- func (q *QUICSettings) AddressFallbackDelay(delay time.Duration) *QUICSettings
- func (q *QUICSettings) AllowConnectionWindowIncrease(allow func(*quic.Conn, uint64) bool) *QUICSettings
- func (q *QUICSettings) ApplicationProbePackets(count uint8) *QUICSettings
- func (q *QUICSettings) ApplicationProbeSkipPacketNumber(enabled bool) *QUICSettings
- func (q *QUICSettings) CachedInitialRTT(parameter uint64, minimum, maximum time.Duration) *QUICSettings
- func (q *QUICSettings) ClientHelloFactory(factory func() (utls.ClientHelloSpec, error)) *QUICSettings
- func (q *QUICSettings) ClientHelloSpec(spec *utls.ClientHelloSpec) *QUICSettings
- func (q *QUICSettings) CoalescePTOProbes(enabled bool) *QUICSettings
- func (q *QUICSettings) CoalesceSmallEarlyPackets(enabled bool) *QUICSettings
- func (q *QUICSettings) CompatibleVersionNegotiation(enabled bool) *QUICSettings
- func (q *QUICSettings) CongestionControl(algorithm CongestionControlAlgorithm) *QUICSettings
- func (q *QUICSettings) CongestionControlConnections(count uint32) *QUICSettings
- func (q *QUICSettings) CongestionControlSegmentSize(bytes uint16) *QUICSettings
- func (q *QUICSettings) ConnectionIDGenerator(generator quic.ConnectionIDGenerator) *QUICSettings
- func (q *QUICSettings) ConnectionIDLength(length int) *QUICSettings
- func (q *QUICSettings) DisableClientHelloScrambling(disabled bool) *QUICSettings
- func (q *QUICSettings) DisableConnectionIDRotation(disable bool) *QUICSettings
- func (q *QUICSettings) DisablePathMTUDiscovery(disabled bool) *QUICSettings
- func (q *QUICSettings) DisableTransportParameterGrease(disabled bool) *QUICSettings
- func (q *QUICSettings) ECHClientHelloInner(policy utls.ECHClientHelloInnerFunc) *QUICSettings
- func (q *QUICSettings) EarlyDataResendOnPeerCrypto(enabled bool) *QUICSettings
- func (q *QUICSettings) EnableDatagrams(enabled bool) *QUICSettings
- func (q *QUICSettings) EnableStreamResetPartialDelivery(enabled bool) *QUICSettings
- func (q *QUICSettings) FlushEarlyData(enabled bool) *QUICSettings
- func (q *QUICSettings) HandshakeAckBeforeData(enabled bool) *QUICSettings
- func (q *QUICSettings) HandshakeCryptoRecovery(enabled bool) *QUICSettings
- func (q *QUICSettings) HandshakeCryptoResendOnPeerProbe(enabled bool) *QUICSettings
- func (q *QUICSettings) HandshakeIdleTimeout(timeout time.Duration) *QUICSettings
- func (q *QUICSettings) HandshakeProbeOnlyWithData(enabled bool) *QUICSettings
- func (q *QUICSettings) HandshakeProbePackets(count uint8) *QUICSettings
- func (q *QUICSettings) HandshakeProbeSkipPacketNumber(enabled bool) *QUICSettings
- func (q *QUICSettings) ImmediateACKOnPeerPing(enabled bool) *QUICSettings
- func (q *QUICSettings) InitialACKResetsPTO(enabled bool) *QUICSettings
- func (q *QUICSettings) InitialCongestionWindowPackets(packets uint32) *QUICSettings
- func (q *QUICSettings) InitialConnectionReceiveWindow(size uint64) *QUICSettings
- func (q *QUICSettings) InitialCryptoCoalescingBarrier(enabled bool) *QUICSettings
- func (q *QUICSettings) InitialCryptoFirstFrameSize(min, max int) *QUICSettings
- func (q *QUICSettings) InitialCryptoFrameSplits(min, max int) *QUICSettings
- func (q *QUICSettings) InitialCryptoLayout(policy func(InitialCryptoLayoutInfo) [][]CryptoRange) *QUICSettings
- func (q *QUICSettings) InitialCryptoProbePackets(count uint8) *QUICSettings
- func (q *QUICSettings) InitialCryptoRecovery(enabled bool) *QUICSettings
- func (q *QUICSettings) InitialCryptoRecoveryLayout(policy func(InitialCryptoLayoutInfo) [][]CryptoRange) *QUICSettings
- func (q *QUICSettings) InitialCryptoResendOnPeerProbe(enabled bool) *QUICSettings
- func (q *QUICSettings) InitialDestinationConnectionIDLength(length int) *QUICSettings
- func (q *QUICSettings) InitialDestinationConnectionIDLengthFactory(factory func() (int, error)) *QUICSettings
- func (q *QUICSettings) InitialPTOMultiplier(factor uint32) *QUICSettings
- func (q *QUICSettings) InitialPacketNumber(number uint64) *QUICSettings
- func (q *QUICSettings) InitialPacketNumberFactory(factory func() (uint64, error)) *QUICSettings
- func (q *QUICSettings) InitialPacketSize(size uint16) *QUICSettings
- func (q *QUICSettings) InitialPacketSizeFactory(factory func(net.Addr) (uint16, error)) *QUICSettings
- func (q *QUICSettings) InitialPaddingMode(mode quic.InitialPaddingMode) *QUICSettings
- func (q *QUICSettings) InitialPingFrames(min, max int) *QUICSettings
- func (q *QUICSettings) InitialProbeSkipPacketNumber(enabled bool) *QUICSettings
- func (q *QUICSettings) InitialRTT(estimate time.Duration) *QUICSettings
- func (q *QUICSettings) InitialStreamReceiveWindow(size uint64) *QUICSettings
- func (q *QUICSettings) KeepAlivePeriod(period time.Duration) *QUICSettings
- func (q *QUICSettings) LegacyAckFrequency(minimum time.Duration) *QUICSettings
- func (q *QUICSettings) MaxAckDelay(delay time.Duration) *QUICSettings
- func (q *QUICSettings) MaxCongestionWindowPackets(packets int64) *QUICSettings
- func (q *QUICSettings) MaxConnectionReceiveWindow(size uint64) *QUICSettings
- func (q *QUICSettings) MaxDatagramFrameSize(size uint64) *QUICSettings
- func (q *QUICSettings) MaxIdleTimeout(timeout time.Duration) *QUICSettings
- func (q *QUICSettings) MaxIncomingStreams(limit int64) *QUICSettings
- func (q *QUICSettings) MaxIncomingUniStreams(limit int64) *QUICSettings
- func (q *QUICSettings) MaxStreamReceiveWindow(size uint64) *QUICSettings
- func (q *QUICSettings) MaxUDPPayloadSize(size uint64) *QUICSettings
- func (q *QUICSettings) MinAckDelay(delay time.Duration) *QUICSettings
- func (q *QUICSettings) OmitInitialAckOnHandshake(omit bool) *QUICSettings
- func (q *QUICSettings) OmitLegacyResetStreamAt(omit bool) *QUICSettings
- func (q *QUICSettings) OmitMaxUDPPayloadSize(omit bool) *QUICSettings
- func (q *QUICSettings) OnApplicationReady(callback func(*quic.Conn)) *QUICSettings
- func (q *QUICSettings) OnEarlyDataReady(callback func(*quic.Conn)) *QUICSettings
- func (q *QUICSettings) OnEarlyDataRejected(callback func(*quic.Conn)) *QUICSettings
- func (q *QUICSettings) Pacing(algorithm PacingAlgorithm) *QUICSettings
- func (q *QUICSettings) PacingBurstPackets(packets uint32) *QUICSettings
- func (q *QUICSettings) PacingGains(slowStart, avoidance uint32) *QUICSettings
- func (q *QUICSettings) PacingGranularity(granularity time.Duration) *QUICSettings
- func (q *QUICSettings) PacingLumpyBurst(packets, windowFraction uint32, minBandwidth uint64) *QUICSettings
- func (q *QUICSettings) PacketNumberLengthPolicy(policy func(quic.PacketNumberLengthInfo) uint8) *QUICSettings
- func (q *QUICSettings) PacketNumberSkipping(enabled bool) *QUICSettings
- func (q *QUICSettings) PeerAckFrequencyPolicy(policy PeerAckFrequencyPolicy) *QUICSettings
- func (q *QUICSettings) PeerPacketRecoveryPolicy(policy func(quic.PeerPacketInfo) quic.PeerPacketRecovery) *QUICSettings
- func (q *QUICSettings) PeerTransportParameters(ids ...uint64) *QUICSettings
- func (q *QUICSettings) PersistentCongestionThreshold(ptos uint32) *QUICSettings
- func (q *QUICSettings) PrioritizeFinishedStreams(enabled bool) *QUICSettings
- func (q *QUICSettings) ProportionalRateReduction(enabled bool) *QUICSettings
- func (q *QUICSettings) ReceiveBatchSize(size int) *QUICSettings
- func (q *QUICSettings) ReceiveWindowUpdateDivisor(divisor uint32) *QUICSettings
- func (q *QUICSettings) RecoveryBurstPackets(packets uint32) *QUICSettings
- func (q *QUICSettings) RequireStreamCreditRelease(required bool) *QUICSettings
- func (q *QUICSettings) ResetAckPolicy() *QUICSettings
- func (q *QUICSettings) ResetInitialPacketProtection() *QUICSettings
- func (q *QUICSettings) ResumeRTT(precision time.Duration) *QUICSettings
- func (q *QUICSettings) ResumeVersion(enabled bool) *QUICSettings
- func (q *QUICSettings) SeparatePacketNumberSpaces(enabled bool) *QUICSettings
- func (q *QUICSettings) Set() *Builder
- func (q *QUICSettings) SlowStart(algorithm SlowStartAlgorithm) *QUICSettings
- func (q *QUICSettings) SortConnectionIDFrames(enabled bool) *QUICSettings
- func (q *QUICSettings) StreamDataRecovery(enabled bool) *QUICSettings
- func (q *QUICSettings) StreamLossRetention(policy func(quic.StreamLossInfo) bool) *QUICSettings
- func (q *QUICSettings) StreamReceiveWindows(bidiLocal, bidiRemote, uni uint64) *QUICSettings
- func (q *QUICSettings) StreamSchedulingByCreation(enabled bool) *QUICSettings
- func (q *QUICSettings) TLSClientFactory(factory tlsquic.NewClient) *QUICSettings
- func (q *QUICSettings) TLSClientFactoryWrapper(wrapper func(*quic.Conn, tlsquic.NewClient) tlsquic.NewClient) *QUICSettings
- func (q *QUICSettings) TokenStore(store quic.TokenStore) *QUICSettings
- func (q *QUICSettings) Tracer(tracer func(context.Context, bool, quic.ConnectionID) qlogwriter.Trace) *QUICSettings
- func (q *QUICSettings) TransportParameter(id uint64, value []byte) *QUICSettings
- func (q *QUICSettings) TransportParameterOrder(ids ...uint64) *QUICSettings
- func (q *QUICSettings) TransportParametersFactory(factory func(quic.Version) (*transportparams.Layout, error)) *QUICSettings
- func (q *QUICSettings) ValidatePeerTransportParameters(validate func([]transportparams.Parameter) error) *QUICSettings
- func (q *QUICSettings) Versions(versions ...quic.Version) *QUICSettings
- type Request
- func (req *Request) AddCookies(cookies ...*http.Cookie) *Request
- func (req *Request) AddHeaders(headers ...any) *Request
- func (req *Request) Body(data any) *Request
- func (req *Request) Do() g.Result[*Response]
- func (req *Request) Fetch() *Request
- func (req *Request) GetRequest() *http.Request
- func (req *Request) HTTP3PriorityUpdates(handler func(*HTTP3PriorityUpdater)) *Request
- func (req *Request) Multipart(m *Multipart) *Request
- func (req *Request) Navigation() *Request
- func (req *Request) SetHeaders(headers ...any) *Request
- func (req *Request) StreamingBody(body io.Reader, length ...int64) *Request
- func (req *Request) StreamingBodyFactory(factory func() (io.ReadCloser, error), length ...int64) *Request
- func (req *Request) WithContext(ctx context.Context) *Request
- type Response
- func (resp Response) Debug() *Debug
- func (resp Response) GetCookies(rawURL g.String) []*http.Cookie
- func (resp Response) GetResponse() *http.Response
- func (resp Response) Location() g.String
- func (resp Response) Referer() g.String
- func (resp Response) RemoteAddress() net.Addr
- func (resp *Response) SetCookies(rawURL g.String, cookies []*http.Cookie) error
- func (resp Response) TLSGrabber() *TLSData
- type SessionCache
- func (s *SessionCache) Both() *SessionCache
- func (s *SessionCache) Brotli(quality int) *SessionCache
- func (s *SessionCache) ByteCapacity(bytes int) *SessionCache
- func (s *SessionCache) Capacity(keys int) *SessionCache
- func (s *SessionCache) ClearEarlyDataOnReject(enabled bool) *SessionCache
- func (s *SessionCache) Clock(clock func() time.Time) *SessionCache
- func (s *SessionCache) Custom(cache tls.ClientSessionCache) *SessionCache
- func (s *SessionCache) DiscardOnExpiry(enabled bool) *SessionCache
- func (s *SessionCache) EvictionPolicy(policy SessionCacheEviction) *SessionCache
- func (s *SessionCache) Group(group func(*tls.ClientSessionState) string) *SessionCache
- func (s *SessionCache) Order(order SessionTicketOrder) *SessionCache
- func (s *SessionCache) QUIC() *SessionCache
- func (s *SessionCache) ReuseTLS12(enabled bool) *SessionCache
- func (s *SessionCache) Set() *Builder
- func (s *SessionCache) Shared(enabled bool) *SessionCache
- func (s *SessionCache) SkipExpired(enabled bool) *SessionCache
- func (s *SessionCache) TCP() *SessionCache
- func (s *SessionCache) TLS12TicketPolicy(policy func(TLS12TicketMetadata) TLS12TicketValidity) *SessionCache
- func (s *SessionCache) TicketsPerKey(tickets int) *SessionCache
- type SessionCacheEviction
- type SessionTicketOrder
- type SlowStartAlgorithm
- type StatusCode
- type StreamReader
- type TCPKeepAliveInfo
- type TCPKeepAliveOptions
- type TLS12TicketMetadata
- type TLS12TicketValidity
- type TLSData
- type TransportAdapter
Constants ΒΆ
const ( HPACKDefault = http2.HPACKDefault HPACKWithoutIndexing = http2.HPACKWithoutIndexing HPACKNeverIndex = http2.HPACKNeverIndex HPACKIncrementalIndexing = http2.HPACKIncrementalIndexing HPACKHuffmanDefault = http2.HPACKHuffmanDefault HPACKHuffmanAlways = http2.HPACKHuffmanAlways HPACKHuffmanNever = http2.HPACKHuffmanNever HPACKNameReferenceDefault = http2.HPACKNameReferenceDefault HPACKNameReferenceLast = http2.HPACKNameReferenceLast HPACKNameReferenceFirst = http2.HPACKNameReferenceFirst )
const ( QPACKEncoderStream = http3.QPACKEncoderStream QPACKDecoderStream = http3.QPACKDecoderStream )
const ( QPACKCapacityOnSettings = http3.QPACKCapacityOnSettings QPACKCapacityBeforeHeaders = http3.QPACKCapacityBeforeHeaders )
const ( QPACKHuffmanDefault = http3.QPACKHuffmanDefault QPACKHuffmanAuto = http3.QPACKHuffmanAuto QPACKHuffmanAlways = http3.QPACKHuffmanAlways QPACKHuffmanNever = http3.QPACKHuffmanNever QPACKIndexAll = http3.QPACKIndexAll QPACKIndexNewNames = http3.QPACKIndexNewNames QPACKIndexNone = http3.QPACKIndexNone )
const ( SETTINGS_QPACK_MAX_TABLE_CAPACITY = h3transport.SETTINGS_QPACK_MAX_TABLE_CAPACITY SETTINGS_MAX_FIELD_SECTION_SIZE = h3transport.SETTINGS_MAX_FIELD_SECTION_SIZE SETTINGS_QPACK_BLOCKED_STREAMS = h3transport.SETTINGS_QPACK_BLOCKED_STREAMS SETTINGS_ENABLE_CONNECT_PROTOCOL = h3transport.SETTINGS_ENABLE_CONNECT_PROTOCOL SETTINGS_H3_DATAGRAM = h3transport.SETTINGS_H3_DATAGRAM H3_DATAGRAM = h3transport.H3_DATAGRAM SETTINGS_ENABLE_WEBTRANSPORT = h3transport.SETTINGS_ENABLE_WEBTRANSPORT )
HTTP/3 SETTINGS frame parameter identifiers as defined in RFC 9114.
const ( InitialPaddingPacket = quic.InitialPaddingPacket InitialPaddingDatagram = quic.InitialPaddingDatagram )
const ( AckReorderingNative = quic.AckReorderingNative AckReorderingImmediate = quic.AckReorderingImmediate AckReorderingWindow = quic.AckReorderingWindow AckECNNative = quic.AckECNNative AckECNTransitions = quic.AckECNTransitions AckECNCountOnly = quic.AckECNCountOnly )
const ( CongestionControlNative = quic.CongestionControlNative CongestionControlReno = quic.CongestionControlReno CongestionControlCubic = quic.CongestionControlCubic CongestionControlCubicBytes = quic.CongestionControlCubicBytes SlowStartNative = quic.SlowStartNative SlowStartClassic = quic.SlowStartClassic SlowStartHybrid = quic.SlowStartHybrid )
const ( PacingNative = quic.PacingNative PacingLeakyBucket = quic.PacingLeakyBucket PacingScheduled = quic.PacingScheduled )
const ( // SessionTicketNewestFirst selects the most recently received ticket. SessionTicketNewestFirst = tlscache.NewestFirst // SessionTicketEarliestExpiryFirst selects the nearest expiry, with new equal-expiry tickets first. SessionTicketEarliestExpiryFirst = tlscache.EarliestExpiryFirst // SessionCacheEvictLeastRecentlyUsed removes the least recently accessed key. SessionCacheEvictLeastRecentlyUsed = tlscache.EvictLeastRecentlyUsed // SessionCacheEvictEarliestExpiry removes individual tickets nearest expiration. SessionCacheEvictEarliestExpiry = tlscache.EvictEarliestExpiry )
Variables ΒΆ
This section is empty.
Functions ΒΆ
This section is empty.
Types ΒΆ
type AckECNMode ΒΆ
type AckECNMode = quic.AckECNMode
type AckReorderingMode ΒΆ
type AckReorderingMode = quic.AckReorderingMode
type Body ΒΆ
type Body struct {
// Underlying body reader (usually http.Response.Body).
// Provides access to the raw response stream.
Reader io.ReadCloser
// contains filtered or unexported fields
}
Body represents an HTTP response body with enhanced functionality and automatic caching. Provides convenient methods for parsing common data formats (JSON, XML, text) and includes features like automatic decompression, content caching, character set detection, and size limits.
func (*Body) Bytes ΒΆ
func (b *Body) Bytes() g.Result[g.Bytes]
Bytes returns the body's content as a byte slice.
func (*Body) Close ΒΆ
Close closes the body and returns any error encountered. It drains remaining data for connection reuse, but respects context cancellation.
func (*Body) Contains ΒΆ
Contains checks if the body's content contains the provided pattern (byte slice, string, or *regexp.Regexp) and returns a boolean.
func (*Body) SSE ΒΆ
SSE reads the body's content as Server-Sent Events (SSE) and calls the provided function for each event. It expects the function to take an *sse.Event pointer as its argument and return a boolean value. If the function returns false, the SSE reading stops.
func (*Body) Stream ΒΆ
func (b *Body) Stream() *StreamReader
Stream returns a bufio.Reader for streaming the body content. IMPORTANT: Call this method once and reuse the returned reader. Each call creates a new bufio.Reader; calling repeatedly in a loop will lose buffered data.
func (*Body) String ΒΆ
func (b *Body) String() g.Result[g.String]
String returns the body's content as a g.String.
func (*Body) UTF8 ΒΆ
func (b *Body) UTF8() g.Result[g.String]
UTF8 converts the body's content to UTF-8 encoding and returns it as a string.
func (*Body) WithContext ΒΆ
WithContext sets the context for cancellation of read operations.
Must be called BEFORE reading the body (Bytes(), String(), Stream(), etc.). Silently ignored if reading has already started.
type Builder ΒΆ
type Builder struct {
// contains filtered or unexported fields
}
Builder provides a fluent interface for configuring HTTP clients with various advanced features including proxy settings, TLS fingerprinting, HTTP/2 and HTTP/3 support, retry logic, redirect handling, and browser impersonation capabilities.
func (*Builder) AddCookies ΒΆ
AddCookies adds cookies to the request.
func (*Builder) AddHeaders ΒΆ
AddHeaders adds headers to the request, appending to any existing headers with the same name.
func (*Builder) BearerAuth ΒΆ
BearerAuth sets the bearer token for the client.
func (*Builder) Build ΒΆ
Build applies all configured settings and returns the client. Returns g.Result with error if any middleware fails.
func (*Builder) CacheBody ΒΆ
CacheBody configures whether the client should cache the body of the response.
func (*Builder) CertificateIntermediates ΒΆ
CertificateIntermediates supplies untrusted issuer candidates for JA-enabled TCP and HTTP/3 certificate verification. The caller's configured roots still decide trust. Chrome presets supply candidates for advertised Trust Anchor IDs. The pool is copied; later builder changes affect future builds. Nil clears it.
func (*Builder) ClientHints ΒΆ
func (b *Builder) ClientHints() *ClientHints
ClientHints opens the client-hint sub-builder. Browser defaults are applied first and explicit settings last, independent of configuration call order.
func (*Builder) ContentType ΒΆ
ContentType sets the content type for the client.
func (*Builder) DNSOverTLS ΒΆ
func (b *Builder) DNSOverTLS() *DNSOverTLS
DNSOverTLS configures the client to use DNS over TLS.
func (*Builder) DisableCompression ΒΆ
DisableCompression disables automatic response body decompression.
func (*Builder) DisableKeepAlive ΒΆ
DisableKeepAlive disable keep-alive connections.
func (*Builder) FollowOnlyHostRedirects ΒΆ
FollowOnlyHostRedirects configures whether the client should only follow redirects within the same host.
func (*Builder) ForceHTTP1 ΒΆ
ForceHTTP1 configures the client to use HTTP/1.1 forcefully.
func (*Builder) ForceHTTP2 ΒΆ
ForceHTTP2 configures the client to use HTTP/2 forcefully.
func (*Builder) ForceHTTP3 ΒΆ
ForceHTTP3 attempts HTTP/3 directly, without requiring Alt-Svc or HTTPS DNS. An unavailable UDP path or a TCP-only proxy can still select HTTP/2 or HTTP/1. Enabled discovery still obtains HTTPS DNS metadata, including ECHConfig.
func (*Builder) ForwardHeadersOnRedirect ΒΆ
ForwardHeadersOnRedirect adds a middleware to the ClientBuilder object that ensures HTTP headers are forwarded during a redirect.
func (*Builder) GetRemoteAddress ΒΆ
GetRemoteAddress configures whether the client should get the remote address.
func (*Builder) HTTP1Settings ΒΆ
func (b *Builder) HTTP1Settings() *HTTP1Settings
HTTP1Settings starts the nested HTTP/1 request-writing builder.
func (*Builder) HTTP2Settings ΒΆ
func (b *Builder) HTTP2Settings() *HTTP2Settings
HTTP2Settings configures settings related to HTTP/2 and returns an http2s struct.
func (*Builder) HTTP3Settings ΒΆ
func (b *Builder) HTTP3Settings() *HTTP3Settings
HTTP3Settings configures settings related to HTTP/3 and returns an http3s struct.
func (*Builder) Impersonate ΒΆ
func (b *Builder) Impersonate() *Impersonate
Impersonate configures something related to impersonation and returns an impersonate struct.
func (*Builder) InterfaceAddr ΒΆ
InterfaceAddr sets the local network interface for outbound connections. Accepts either an IP address (e.g., "192.168.1.100", "::1") or an interface name (e.g., "eth0", "en0").
func (*Builder) MaxRedirects ΒΆ
MaxRedirects sets the maximum number of redirects the client should follow.
func (*Builder) NetworkSettings ΒΆ
func (b *Builder) NetworkSettings() *NetworkSettings
NetworkSettings starts the nested network-notification builder. Plain clients have no automatic subscription; browser profiles provide their own policy.
func (*Builder) NotFollowRedirects ΒΆ
NotFollowRedirects disables following redirects for the client.
func (*Builder) QUICSettings ΒΆ
func (b *Builder) QUICSettings() *QUICSettings
QUICSettings configures the QUIC transport used by HTTP/3. Set returns this Builder, as with HTTP2Settings and HTTP3Settings.
func (*Builder) RedirectPolicy ΒΆ
RedirectPolicy sets a custom redirect policy for the client.
func (*Builder) Retry ΒΆ
Retry configures the retry behavior of the client.
Parameters:
retryMax: Maximum number of retry attempts. If zero or negative the
retry loop is disabled.
retryWait: Minimum wait between retries. If the server responds with a
Retry-After header on a retryable status, the actual pause
becomes max(retryWait, Retry-After). Both legal forms are
honoured: integer delay-seconds and HTTP-date (IMF-fixdate,
RFC 850, ANSI C asctime). Absent or malformed values fall
back to retryWait.
codes: Optional list of HTTP status codes that trigger retries.
If no codes are provided, the defaults are used
(500 Internal Server Error, 429 Too Many Requests,
503 Service Unavailable).
Upper bound for the entire retry cycle, including a long Retry-After sleep, is the request context deadline β set it with Request.WithContext(ctxWithDeadline). Builder.Timeout only bounds a single cli.Do invocation (connect + transmission + body read); it does not interrupt the sleep between retries.
func (*Builder) SecureTLS ΒΆ
SecureTLS enables TLS certificate verification. By default surf skips certificate verification (InsecureSkipVerify=true). Call this for production use where certificate validation is required.
func (*Builder) SessionCache ΒΆ
func (b *Builder) SessionCache() *SessionCache
SessionCache starts the nested ticket-cache builder. Browser defaults are applied first, followed by explicit settings, regardless of chain order. Each call selects both transports; TCP and QUIC narrow subsequent settings.
func (*Builder) SetHeaders ΒΆ
SetHeaders sets headers for the request, replacing existing ones with the same name.
func (*Builder) UnixSocket ΒΆ
UnixSocket sets the path for a Unix domain socket. This allows the HTTP client to connect to the server using a Unix domain socket instead of a traditional TCP/IP connection.
func (*Builder) WebSocketGuard ΒΆ
WebSocketGuard enables middleware that blocks WebSocket upgrade responses (HTTP 101). Without this, surf allows 101 Switching Protocols to pass through β compatible with websocket.Dial and other WebSocket libraries that use surf.Std() as HTTPClient. Enable this only if you want to explicitly reject unexpected WebSocket upgrades.
func (*Builder) With ΒΆ
With registers middleware into the client builder with optional priority.
It accepts one of the following middleware function types:
- func(*surf.Client) error β client middleware, modifies or initializes the client
- func(*surf.Request) error β request middleware, intercepts or transforms outgoing requests
- func(*surf.Response) error β response middleware, intercepts or transforms incoming responses
Parameters:
- middleware: A function matching one of the supported middleware types.
- priority (optional): Integer priority level. Lower values run earlier. Defaults to 0.
Middleware with the same priority are executed in order of insertion (FIFO). If the middleware type is not recognized, With panics with an informative error.
Example:
// Adding client middleware to modify client settings.
.With(func(client *surf.Client) error {
// Custom logic to modify the client settings.
return nil
})
// Adding request middleware to intercept outgoing requests.
.With(func(req *surf.Request) error {
// Custom logic to modify outgoing requests.
return nil
})
// Adding response middleware to intercept incoming responses.
.With(func(resp *surf.Response) error {
// Custom logic to handle incoming responses.
return nil
})
Note: Ensure that middleware functions adhere to the specified function signatures to work correctly with the With method.
type Client ΒΆ
type Client struct {
// contains filtered or unexported fields
}
Client represents a highly configurable HTTP client with middleware support, advanced transport options (HTTP/1.1, HTTP/2, HTTP/3), proxy handling, TLS fingerprinting, and comprehensive request/response processing capabilities.
func NewClient ΒΆ
func NewClient() *Client
NewClient creates a new Client with sensible default settings including default dialer, TLS configuration, HTTP transport, and basic middleware.
func (*Client) Builder ΒΆ
Builder returns a new Builder instance associated with this client. The builder allows for method chaining to configure various client options.
func (*Client) ClearClientHints ΒΆ
func (c *Client) ClearClientHints()
ClearClientHints clears learned origin opt-ins without closing connections or changing configured metadata. It is safe alongside concurrent requests.
func (*Client) ClientHintNames ΒΆ
ClientHintNames returns a copy of the remembered opt-in names for a URL's origin. It reports no opt-ins when negotiation is not installed.
func (*Client) Close ΒΆ
Close completely shuts down the client and releases all resources. After calling Close, the client should not be used.
func (*Client) CloseIdleConnections ΒΆ
func (c *Client) CloseIdleConnections()
CloseIdleConnections closes idle connections while keeping the client usable. Safe to call periodically to free resources during long-running operations.
func (*Client) Connect ΒΆ
Connect creates a new HTTP CONNECT request for the specified URL. CONNECT requests are used to establish a tunnel to the server.
func (*Client) Delete ΒΆ
Delete creates a new HTTP DELETE request for the specified URL. DELETE requests are used to remove a resource from a server.
func (*Client) Get ΒΆ
Get creates a new HTTP GET request for the specified URL. GET requests are used to retrieve data from a server.
func (*Client) GetClient ΒΆ
func (c *Client) GetClient() *http.Client
GetClient returns http.Client used by the Client.
func (*Client) GetTLSConfig ΒΆ
GetTLSConfig returns the tls.Config used by the Client.
func (*Client) GetTransport ΒΆ
func (c *Client) GetTransport() http.RoundTripper
GetTransport returns the http.transport used by the Client.
func (*Client) Head ΒΆ
Head creates a new HTTP HEAD request for the specified URL. HEAD requests are identical to GET but without the response body.
func (*Client) NetworkChanged ΒΆ
func (c *Client) NetworkChanged(changes ...NetworkChangeInfo)
NetworkChanged immediately applies the built network policy. With no argument it describes a stable address/link/route change. Applications that already own notifications can disable Automatic and call this hook. Native notifications use the configured coalescing delay; explicit calls are already-delivered events.
func (*Client) Options ΒΆ
Options creates a new HTTP OPTIONS request for the specified URL. OPTIONS requests are used to describe the communication options for a resource.
func (*Client) Patch ΒΆ
Patch creates a new HTTP PATCH request for the specified URL. PATCH requests are used to apply partial modifications to a resource.
func (*Client) Post ΒΆ
Post creates a new HTTP POST request for the specified URL. POST requests are used to submit data to a server.
func (*Client) Put ΒΆ
Put creates a new HTTP PUT request for the specified URL. PUT requests are used to replace a resource on a server.
func (*Client) Raw ΒΆ
Raw creates a new HTTP request using the provided raw data and scheme. The raw parameter should contain the raw HTTP request data as a string. The scheme parameter specifies the scheme (e.g., http, https) for the request.
func (*Client) Std ΒΆ
Std returns a standard net/http.Client that wraps the configured surf client. This is useful for integrating with third-party libraries that expect a standard net/http.Client while preserving most surf features.
Supported features:
- JA3/TLS fingerprinting
- HTTP/2 settings
- Cookies and sessions
- Request/Response middleware
- Headers (User-Agent, custom headers)
- Proxy configuration
- Timeout settings
- Redirect policies
- Impersonate browser headers
Known limitations:
- Retry logic is NOT supported (implemented in Request.Do(), not in transport)
- Response body caching is NOT supported
- Remote address tracking is NOT supported
- Request timing information is NOT available
For applications requiring retry logic, consider implementing it at the application level or use surf.Client directly for those specific requests.
Example usage:
surfClient := surf.NewClient().
Builder().
JA3().Chrome().
Session().
Build()
// For libraries expecting net/http.Client
stdClient := surfClient.Std()
botClient := &BaseBotClient{
Client: *stdClient,
}
type ClientHintBrand ΒΆ
type ClientHintBrand struct {
// Brand is the product name or GREASE brand.
Brand string
// Version is the complete version advertised for this brand.
Version string
}
ClientHintBrand describes one brand in Sec-CH-UA-Full-Version-List.
type ClientHints ΒΆ
type ClientHints struct {
// contains filtered or unexported fields
}
ClientHints is Surf's fluent configuration for available Client Hints and origin opt-ins. Chrome desktop/Android enable negotiation automatically. Other clients can enable it with Set. Explicit request headers take precedence.
func (*ClientHints) ALPS ΒΆ
func (h *ClientHints) ALPS(value bool) *ClientHints
ALPS applies available hints requested by the selected TLS connection's authenticated ACCEPT_CH instructions. It does not persist them as response opt-ins. Enabled by default with negotiation; protocol SETTINGS remain active.
func (*ClientHints) Architecture ΒΆ
func (h *ClientHints) Architecture(value string) *ClientHints
Architecture sets sec-ch-ua-arch, such as x86 or arm; Android normally uses empty.
func (*ClientHints) Bitness ΒΆ
func (h *ClientHints) Bitness(value string) *ClientHints
Bitness sets sec-ch-ua-bitness, such as 64 or 32; Android normally uses empty.
func (*ClientHints) Capacity ΒΆ
func (h *ClientHints) Capacity(value int) *ClientHints
Capacity bounds remembered origins to 1..1048576; the default is 1024.
func (*ClientHints) ClearSiteData ΒΆ
func (h *ClientHints) ClearSiteData(value bool) *ClientHints
ClearSiteData permits secure response directives to clear this client's remembered hint opt-ins. Clearing directives also suppress same-response Accept-CH/Critical-CH, even when invalidation is disabled or the directive cannot clear storage. This follows Chromium's separate parsed-header gate. It does not clear cookies, HTTP cache or storage. Enabled by default with negotiation. Surf has no DOM credential/storage context; applications can disable this client-local invalidation when applying their own context policy.
func (*ClientHints) Clock ΒΆ
func (h *ClientHints) Clock(value func() time.Time) *ClientHints
Clock supplies origin-cache time and must support concurrent calls. Nil restores time.Now.
func (*ClientHints) Enabled ΒΆ
func (h *ClientHints) Enabled(value bool) *ClientHints
Enabled controls negotiation and emission of learned hints. Explicit request headers, including the profile's static low-entropy fields, remain caller-owned.
func (*ClientHints) FormFactors ΒΆ
func (h *ClientHints) FormFactors(values ...string) *ClientHints
FormFactors supplies ordered form-factor strings, such as Desktop or Mobile.
func (*ClientHints) FullVersion ΒΆ
func (h *ClientHints) FullVersion(value string) *ClientHints
FullVersion sets the complete browser version and updates matching product entries in its full-version list, leaving the GREASE version independent.
func (*ClientHints) FullVersionList ΒΆ
func (h *ClientHints) FullVersionList(values ...ClientHintBrand) *ClientHints
FullVersionList supplies ordered complete product and GREASE versions.
func (*ClientHints) Lifetime ΒΆ
func (h *ClientHints) Lifetime(value time.Duration) *ClientHints
Lifetime bounds opt-in retention. Zero keeps in-memory state for this client.
func (*ClientHints) Model ΒΆ
func (h *ClientHints) Model(value string) *ClientHints
Model sets the device model; desktop Chrome uses an empty model.
func (*ClientHints) PlatformVersion ΒΆ
func (h *ClientHints) PlatformVersion(value string) *ClientHints
PlatformVersion sets the target OS version, independent of the Go host OS.
func (*ClientHints) Set ΒΆ
func (h *ClientHints) Set() *Builder
Set applies the accumulated configuration and returns the ordinary client builder. Invalid names, values or limits are reported by Builder.Build.
func (*ClientHints) Value ΒΆ
func (h *ClientHints) Value(name, value string) *ClientHints
Value supplies a serialized recognized hint value, emitted only when opted in unless Chromium sends that hint by default. Unknown names fail Builder.Build.
func (*ClientHints) WoW64 ΒΆ
func (h *ClientHints) WoW64(value bool) *ClientHints
WoW64 reports a 32-bit Chrome process running on 64-bit Windows.
type CongestionControlAlgorithm ΒΆ
type CongestionControlAlgorithm = quic.CongestionControlAlgorithm
type ConnectionRacingInfo ΒΆ
type ConnectionRacingInfo = profiles.ConnectionRacingInfo
type ConnectionRacingPolicy ΒΆ
type ConnectionRacingPolicy = profiles.ConnectionRacingPolicy
type CookieJarAdapter ΒΆ
type CookieJarAdapter struct {
// contains filtered or unexported fields
}
CookieJarAdapter adapts github.com/alvarorichard/enetx-http.CookieJar to net/http.CookieJar. It provides bidirectional cookie conversion between the two HTTP packages, ensuring cookies set through either interface work correctly.
func (*CookieJarAdapter) Cookies ΒΆ
func (c *CookieJarAdapter) Cookies(u *url.URL) []*_http.Cookie
Cookies implements http.CookieJar interface. It retrieves cookies from the underlying surf cookie jar and converts them to standard net/http cookie format.
func (*CookieJarAdapter) SetCookies ΒΆ
func (c *CookieJarAdapter) SetCookies(u *url.URL, _cookies []*_http.Cookie)
SetCookies implements http.CookieJar interface. It converts standard net/http cookies to enetx/http format and delegates to the underlying surf cookie jar.
type Cookies ΒΆ
type Cookies []*http.Cookie
Cookies represents a list of HTTP Cookies.
type CryptoRange ΒΆ
type CryptoRange = quic.CryptoRange
CryptoRange selects a byte range in the first ClientHello's CRYPTO stream.
type DNSOverTLS ΒΆ
type DNSOverTLS struct {
// contains filtered or unexported fields
}
DNSOverTLS is a configuration struct for DNS over TLS settings.
func (*DNSOverTLS) AdGuard ΒΆ
func (dot *DNSOverTLS) AdGuard() *Builder
AdGuard sets up DNS over TLS with AdGuard DNS.
func (*DNSOverTLS) AddProvider ΒΆ
func (dot *DNSOverTLS) AddProvider(serverName g.String, addresses ...g.String) *Builder
AddProvider sets up DNS over TLS with a custom DNS provider. It configures a custom net.Resolver using the resolver method.
func (*DNSOverTLS) Ali ΒΆ
func (dot *DNSOverTLS) Ali() *Builder
Ali sets up DNS over TLS with AliDNS.
func (*DNSOverTLS) CIRAShield ΒΆ
func (dot *DNSOverTLS) CIRAShield() *Builder
CIRAShield sets up DNS over TLS with CIRA Canadian Shield DNS.
func (*DNSOverTLS) Cloudflare ΒΆ
func (dot *DNSOverTLS) Cloudflare() *Builder
Cloudflare sets up DNS over TLS with Cloudflare DNS.
func (*DNSOverTLS) Forge ΒΆ
func (dot *DNSOverTLS) Forge() *Builder
Forge sets up DNS over TLS with DNS Forge.
func (*DNSOverTLS) Google ΒΆ
func (dot *DNSOverTLS) Google() *Builder
Google sets up DNS over TLS with Google Public DNS.
func (*DNSOverTLS) LibreDNS ΒΆ
func (dot *DNSOverTLS) LibreDNS() *Builder
LibreDNS sets up DNS over TLS with LibreDNS.
func (*DNSOverTLS) Quad9 ΒΆ
func (dot *DNSOverTLS) Quad9() *Builder
Quad9 sets up DNS over TLS with Quad9 DNS.
func (*DNSOverTLS) Quad101 ΒΆ
func (dot *DNSOverTLS) Quad101() *Builder
Quad101 sets up DNS over TLS with Quad101 DNS.
func (*DNSOverTLS) SB ΒΆ
func (dot *DNSOverTLS) SB() *Builder
SB sets up DNS over TLS with Secure DNS (dot.sb).
func (*DNSOverTLS) Switch ΒΆ
func (dot *DNSOverTLS) Switch() *Builder
Switch sets up DNS over TLS with SWITCH DNS.
type Debug ΒΆ
type Debug struct {
// contains filtered or unexported fields
}
Debug is a struct that holds debugging information for an HTTP response.
type EarlyRequestPolicy ΒΆ
type EarlyRequestPolicy = profiles.EarlyRequestPolicy
EarlyRequestPolicy adds a history-based gate to safe HTTP/3 early requests.
type Err101ResponseCode ΒΆ
type Err101ResponseCode struct{ Msg string }
Err101ResponseCode indicates a 101 Switching Protocols response was received. This error is used to handle HTTP 101 responses that require protocol upgrades.
func (*Err101ResponseCode) Error ΒΆ
func (e *Err101ResponseCode) Error() string
type ErrHTTP2Fallback ΒΆ
ErrHTTP2Fallback indicates that an HTTPS request attempted HTTP/2 first, then tried to fall back to HTTP/1.1, but both attempts failed.
Both underlying errors are accessible via Unwrap, enabling errors.Is and errors.As to match against either the HTTP/2 or HTTP/1.1 failure.
func (*ErrHTTP2Fallback) Error ΒΆ
func (e *ErrHTTP2Fallback) Error() string
func (*ErrHTTP2Fallback) Unwrap ΒΆ
func (e *ErrHTTP2Fallback) Unwrap() []error
type ErrUserAgentType ΒΆ
type ErrUserAgentType struct{ Msg string }
ErrUserAgentType indicates an invalid user agent type was provided. This error is returned when the user agent parameter is not of a supported type (string, g.String, slices, etc.).
func (*ErrUserAgentType) Error ΒΆ
func (e *ErrUserAgentType) Error() string
type ErrWebSocketUpgrade ΒΆ
type ErrWebSocketUpgrade struct{ Msg string }
ErrWebSocketUpgrade indicates that a request received a WebSocket upgrade response. This error is returned when the server responds with HTTP 101 Switching Protocols for WebSocket connections, which require special handling.
func (*ErrWebSocketUpgrade) Error ΒΆ
func (e *ErrWebSocketUpgrade) Error() string
type HPACKHuffmanMode ΒΆ
type HPACKHuffmanMode = http2.HPACKHuffmanMode
HPACKRepresentation selects how a request or trailer field is encoded.
type HPACKNameReferencePolicy ΒΆ
type HPACKNameReferencePolicy = http2.HPACKNameReferencePolicy
HPACKRepresentation selects how a request or trailer field is encoded.
type HPACKRepresentation ΒΆ
type HPACKRepresentation = http2.HPACKRepresentation
HPACKRepresentation selects how a request or trailer field is encoded.
type HTTP1Settings ΒΆ
type HTTP1Settings struct {
// contains filtered or unexported fields
}
HTTP1Settings configures owned HTTP/1 request buffers and write packing. Browser defaults apply first; explicit fluent overrides apply last.
func (*HTTP1Settings) BodyReadSize ΒΆ
func (h *HTTP1Settings) BodyReadSize(size int) *HTTP1Settings
BodyReadSize bounds body reads, zero through 1 MiB. Zero retains native copy optimizations. Explicit sizes also apply to file and streaming bodies.
func (*HTTP1Settings) HeaderBodyMergeLimit ΒΆ
func (h *HTTP1Settings) HeaderBodyMergeLimit(limit int64) *HTTP1Settings
HeaderBodyMergeLimit selects the largest combined header/in-memory-body write. Zero separates nonempty bodies; the valid range is zero through 1 MiB. Potentially blocking bodies and Expect/Continue retain their required flush.
func (*HTTP1Settings) Set ΒΆ
func (h *HTTP1Settings) Set() *Builder
Set returns to the client builder.
func (*HTTP1Settings) WriteBufferSize ΒΆ
func (h *HTTP1Settings) WriteBufferSize(size int) *HTTP1Settings
WriteBufferSize selects the outgoing HTTP/1 buffer size, zero through 1 MiB. Zero restores the native default.
type HTTP2ConnectionCloseInfo ΒΆ
type HTTP2ConnectionCloseInfo = http2.ConnectionCloseInfo
HTTP2ConnectionCloseInfo describes a terminal HTTP/2 connection close.
type HTTP2ConnectionCloseOptions ΒΆ
type HTTP2ConnectionCloseOptions = http2.ConnectionCloseOptions
HTTP2ConnectionCloseOptions selects the optional final GOAWAY frame.
type HTTP2ReceiveWindowUpdateInfo ΒΆ
type HTTP2ReceiveWindowUpdateInfo = http2.ReceiveWindowUpdateInfo
type HTTP2RequestBodyInfo ΒΆ
type HTTP2RequestBodyInfo = http2.RequestBodyInfo
HTTP2RequestBodyInfo describes effective request fields and content length.
type HTTP2RequestBodyOptions ΒΆ
type HTTP2RequestBodyOptions = http2.RequestBodyOptions
HTTP2RequestBodyOptions controls upload reads and DATA framing.
type HTTP2Settings ΒΆ
type HTTP2Settings struct {
// contains filtered or unexported fields
}
HTTP2Settings represents HTTP/2 settings. https://lwthiker.com/networks/2022/06/17/http2-fingerprinting.html
func (*HTTP2Settings) ChainStreamDependencies ΒΆ
func (h *HTTP2Settings) ChainStreamDependencies(enabled bool) *HTTP2Settings
ChainStreamDependencies selects the newest still-open earlier stream with equal or greater weight as the dependency. Exclusive remains caller-controlled.
func (*HTTP2Settings) ConnectionClosePolicy ΒΆ
func (h *HTTP2Settings) ConnectionClosePolicy( policy func(HTTP2ConnectionCloseInfo) HTTP2ConnectionCloseOptions, ) *HTTP2Settings
ConnectionClosePolicy selects a final GOAWAY on terminal HTTP/2 close. Nil retains native behavior. The callback runs once outside connection locks and must return promptly, be concurrency safe and not reenter the connection.
func (*HTTP2Settings) ConnectionFlow ΒΆ
func (h *HTTP2Settings) ConnectionFlow(size uint32) *HTTP2Settings
ConnectionFlow sets the flow control for the HTTP/2 connection.
func (*HTTP2Settings) EnablePush ΒΆ
func (h *HTTP2Settings) EnablePush(size uint32) *HTTP2Settings
EnablePush enables HTTP/2 server push functionality.
func (*HTTP2Settings) HTTP1RequiredCache ΒΆ
func (h *HTTP2Settings) HTTP1RequiredCache(capacity int) *HTTP2Settings
HTTP1RequiredCache bounds remembered HTTPS origins requiring HTTP/1 in the JA TCP transport. Zero disables remembering and keeps per-request fallback. Chrome profiles select 100; Firefox and generic TLS profiles keep it disabled. Entries are client-local LRU state shared by proxy routes, without a TTL or disk persistence. HTTP/3 remains eligible. The valid range is 0..1048576.
func (*HTTP2Settings) HeaderPriority ΒΆ
func (h *HTTP2Settings) HeaderPriority(policy func(http2.PriorityRequest) http2.PriorityParam) *HTTP2Settings
HeaderPriority selects HTTP/2 HEADERS priority per request. The request is a read-only view. The callback must be safe for concurrent connections and must not reenter the client. Nil restores PriorityParam.
func (*HTTP2Settings) HeaderTableSize ΒΆ
func (h *HTTP2Settings) HeaderTableSize(size uint32) *HTTP2Settings
HeaderTableSize sets the header table size for HTTP/2 settings.
func (*HTTP2Settings) HealthCheckPayload ΒΆ
func (h *HTTP2Settings) HealthCheckPayload(payload *[8]byte) *HTTP2Settings
HealthCheckPayload selects automatic idle-PING data. Nil restores random payloads. The value is copied; explicit Ping and peer-PING echoes are unchanged.
func (*HTTP2Settings) HpackDeduplicateTableSizeUpdates ΒΆ
func (h *HTTP2Settings) HpackDeduplicateTableSizeUpdates(enabled bool) *HTTP2Settings
HpackDeduplicateTableSizeUpdates suppresses updates for repeated peer table capacities while retaining pending shrink/grow instructions.
func (*HTTP2Settings) HpackDefaultRepresentation ΒΆ
func (h *HTTP2Settings) HpackDefaultRepresentation(rep HPACKRepresentation) *HTTP2Settings
HpackDefaultRepresentation sets the fallback for fields without an override. HPACKDefault retains upstream indexing, table eviction and Huffman behavior.
func (*HTTP2Settings) HpackHuffman ΒΆ
func (h *HTTP2Settings) HpackHuffman(mode HPACKHuffmanMode) *HTTP2Settings
HpackHuffman chooses automatic, always or disabled Huffman string encoding.
func (*HTTP2Settings) HpackIndexingLimit ΒΆ
func (h *HTTP2Settings) HpackIndexingLimit(limit func(tableCapacity uint32) uint32) *HTTP2Settings
HpackIndexingLimit bounds new dynamic entries by their HPACK size (including 32 bytes of overhead), as a function of the current encoder table capacity. Existing exact entries remain reusable. Nil restores the upstream limit.
func (*HTTP2Settings) HpackNameReferencePolicy ΒΆ
func (h *HTTP2Settings) HpackNameReferencePolicy(policy HPACKNameReferencePolicy) *HTTP2Settings
HpackNameReferencePolicy controls which matching field name a literal refers to.
func (*HTTP2Settings) HpackPolicy ΒΆ
func (h *HTTP2Settings) HpackPolicy(policy func(name, value string) HPACKRepresentation) *HTTP2Settings
HpackPolicy selects representations by field name and value. Per-name HpackRepresentation overrides take precedence. The callback must be safe for concurrent connections and must not reenter the client.
func (*HTTP2Settings) HpackRepresentation ΒΆ
func (h *HTTP2Settings) HpackRepresentation(name string, rep HPACKRepresentation) *HTTP2Settings
HpackRepresentation overrides the policy for one field, including pseudo-fields.
func (*HTTP2Settings) InitialPeerSettings ΒΆ
func (h *HTTP2Settings) InitialPeerSettings( policy func([]http2.Setting) ([]http2.Setting, error), ) *HTTP2Settings
InitialPeerSettings selects which authenticated ALPS settings initialize an HTTP/2 connection. It receives a private slice before the first HTTP bytes, must return promptly and be safe across connections. Errors abort the unsent connection. Nil uses the native engine's settings semantics. Ordinary wire SETTINGS remain owned by the HTTP engine. Set this after Impersonate to override the selected profile's initial-settings policy.
func (*HTTP2Settings) InitialStreamID ΒΆ
func (h *HTTP2Settings) InitialStreamID(id uint32) *HTTP2Settings
InitialStreamID sets the initial stream id for HTTP/2 streams.
func (*HTTP2Settings) InitialWindowSize ΒΆ
func (h *HTTP2Settings) InitialWindowSize(size uint32) *HTTP2Settings
InitialWindowSize sets the initial window size for HTTP/2 streams.
func (*HTTP2Settings) MaxConcurrentStreams ΒΆ
func (h *HTTP2Settings) MaxConcurrentStreams(size uint32) *HTTP2Settings
MaxConcurrentStreams sets the maximum number of concurrent streams in HTTP/2.
func (*HTTP2Settings) MaxEncoderHeaderTableSize ΒΆ
func (h *HTTP2Settings) MaxEncoderHeaderTableSize(size uint32) *HTTP2Settings
MaxEncoderHeaderTableSize bounds the request encoder's table, independently of HeaderTableSize (our advertised decoder capacity). Zero retains upstream defaults. The native engine supports limits up to math.MaxInt32.
func (*HTTP2Settings) MaxFrameSize ΒΆ
func (h *HTTP2Settings) MaxFrameSize(size uint32) *HTTP2Settings
MaxFrameSize sets the maximum frame size for HTTP/2 frames.
func (*HTTP2Settings) MaxHeaderListSize ΒΆ
func (h *HTTP2Settings) MaxHeaderListSize(size uint32) *HTTP2Settings
MaxHeaderListSize sets the maximum size of the header list in HTTP/2.
func (*HTTP2Settings) NoRFC7540Priorities ΒΆ
func (h *HTTP2Settings) NoRFC7540Priorities(size uint32) *HTTP2Settings
NoRFC7540Priorities disables RFC 7540 priority signaling in HTTP/2.
func (*HTTP2Settings) PingTimeout ΒΆ
func (h *HTTP2Settings) PingTimeout(timeout time.Duration) *HTTP2Settings
PingTimeout bounds an automatic HTTP/2 health PING's acknowledgement wait. Zero retains the HTTP engine default. Negative durations are invalid.
func (*HTTP2Settings) PriorityFrames ΒΆ
func (h *HTTP2Settings) PriorityFrames(priorityFrames []http2.PriorityFrame) *HTTP2Settings
PriorityFrames sets the priority frames for HTTP/2.
func (*HTTP2Settings) PriorityParam ΒΆ
func (h *HTTP2Settings) PriorityParam(priorityParam http2.PriorityParam) *HTTP2Settings
PriorityParam sets a fixed HTTP/2 HEADERS priority and replaces HeaderPriority. Stream dependency chaining remains independently controlled by ChainStreamDependencies.
func (*HTTP2Settings) ReadIdleTimeout ΒΆ
func (h *HTTP2Settings) ReadIdleTimeout(timeout time.Duration) *HTTP2Settings
ReadIdleTimeout schedules an HTTP/2 health PING after this period without peer frames. Zero disables periodic probes. Browser profiles override the generic transport default; it is independent of TCP socket keepalive.
func (*HTTP2Settings) ReceiveWindowUpdatePolicy ΒΆ
func (h *HTTP2Settings) ReceiveWindowUpdatePolicy(policy func(HTTP2ReceiveWindowUpdateInfo) bool) *HTTP2Settings
ReceiveWindowUpdatePolicy controls batching of returned HTTP/2 receive credit. Nil restores native behavior. The callback runs under the connection lock; it must return promptly, be concurrency safe and never reenter the transport. An installed policy owns batching even when the peer's advertised credit is exhausted. It must eventually return consumed credit to permit more data.
func (*HTTP2Settings) RequestBodyPolicy ΒΆ
func (h *HTTP2Settings) RequestBodyPolicy( policy func(HTTP2RequestBodyInfo) HTTP2RequestBodyOptions, ) *HTTP2Settings
RequestBodyPolicy selects upload source-read boundaries and DATA limits from effective wire fields, without consuming the body. Nil uses native behavior. The callback must be concurrency safe and never reenter the transport.
func (*HTTP2Settings) Set ΒΆ
func (h *HTTP2Settings) Set() *Builder
Set applies the accumulated HTTP/2 settings. It configures the HTTP/2 settings for the surf client.
func (*HTTP2Settings) StreamReceiveWindow ΒΆ
func (h *HTTP2Settings) StreamReceiveWindow(size uint32) *HTTP2Settings
StreamReceiveWindow raises each client-created stream's credit after HEADERS. Zero uses InitialWindowSize; a nonzero window must be at least that size.
func (*HTTP2Settings) WriteBufferSize ΒΆ
func (h *HTTP2Settings) WriteBufferSize(size int) *HTTP2Settings
WriteBufferSize sets the HTTP/2 connection writer buffer. Zero retains the native default; the maximum is 1 MiB. Each DATA frame is still flushed.
type HTTP3GreaseFrame ΒΆ
type HTTP3GreaseFrame = http3.GreaseFrame
HTTP3GreaseFrame describes one RFC 9114 reserved frame and its payload.
type HTTP3PriorityUpdater ΒΆ
type HTTP3PriorityUpdater = http3.PriorityUpdater
HTTP3PriorityUpdater queues RFC 9218 priority changes for one open request. Update is concurrency safe; it does not change local QUIC upload scheduling.
type HTTP3RequestBodyReadInfo ΒΆ
type HTTP3RequestBodyReadInfo = http3.RequestBodyReadInfo
HTTP3RequestBodyReadInfo contains validated wire fields and the effective buffer size.
type HTTP3Settings ΒΆ
type HTTP3Settings struct {
// contains filtered or unexported fields
}
HTTP3Settings configures HTTP/3 SETTINGS, response limits and request options. Use Builder.QUICSettings for the underlying QUIC transport and handshake.
func (*HTTP3Settings) AdditionalSettings ΒΆ
func (h *HTTP3Settings) AdditionalSettings(settings g.MapOrd[uint64, uint64]) *HTTP3Settings
AdditionalSettings merges ordered HTTP/3 SETTINGS. Existing keys keep their position; new keys append in input order. Advertising a setting does not add implementation support for extensions such as WebTransport. QPACK settings configure the receive-side decoder; request encoding is configured separately.
func (*HTTP3Settings) AltUsed ΒΆ
func (h *HTTP3Settings) AltUsed(enabled bool) *HTTP3Settings
AltUsed sends the current request's destination authority in the Alt-Used header on HTTP/3 attempts. The Firefox desktop profile enables this to match its captured alternative-service requests. Explicit headers take precedence. Port 443 is omitted; non-default ports and IPv6 brackets are preserved.
func (*HTTP3Settings) AlternativeServiceBackoff ΒΆ
func (h *HTTP3Settings) AlternativeServiceBackoff(policy AlternativeServiceBackoff) *HTTP3Settings
AlternativeServiceBackoff selects the retry delay after a failed alternative handshake. Cancellation and a TCP race win do not count as service failure. The callback must be prompt, concurrency safe, and must not reenter this client.
func (*HTTP3Settings) ClientHandshake ΒΆ
func (h *HTTP3Settings) ClientHandshake(config *quic.ClientHandshake) *HTTP3Settings
ClientHandshake sets optional QUIC handshake controls. The supplied values are snapshotted; nil removes this override and retains any QUICConfig controls. Use Builder.QUICSettings for fluent configuration of individual controls.
func (*HTTP3Settings) ClientHelloFactory ΒΆ
func (h *HTTP3Settings) ClientHelloFactory(factory func() (utls.ClientHelloSpec, error)) *HTTP3Settings
ClientHelloFactory supplies a fresh QUIC template per connection attempt, including retries after version negotiation. The factory may run concurrently. Returned templates must not share mutable extensions with other attempts.
func (*HTTP3Settings) ClientHelloSpec ΒΆ
func (h *HTTP3Settings) ClientHelloSpec(spec *utls.ClientHelloSpec) *HTTP3Settings
ClientHelloSpec sets an explicit QUIC ClientHello template. It must contain QUICTransportParametersExtension and ALPNExtension; TCP templates are rejected. QUIC supplies real transport parameters and the HTTP/3 ALPN for each dial. Browser TCP JA settings remain independent. Nil restores standard crypto/tls.
func (*HTTP3Settings) CoalesceInitialSettings ΒΆ
func (h *HTTP3Settings) CoalesceInitialSettings(enabled bool) *HTTP3Settings
CoalesceInitialSettings prepares SETTINGS before the first application flight when peer credit permits. With early keys, preparation precedes Initial packetization unless FlushEarlySettings is enabled. Backpressure keeps an asynchronous write on the same stream. Control-frame factories must not block.
func (*HTTP3Settings) CoalesceRequestHeaders ΒΆ
func (h *HTTP3Settings) CoalesceRequestHeaders(enabled bool) *HTTP3Settings
CoalesceRequestHeaders stages initial priority, ready QPACK encoder instructions, HEADERS and a bodyless request's FIN together. Busy or blocked critical streams retain their asynchronous writer without holding requests.
func (*HTTP3Settings) CompactPriorityUpdates ΒΆ
func (h *HTTP3Settings) CompactPriorityUpdates(enabled bool) *HTTP3Settings
CompactPriorityUpdates omits spaces after commas in PRIORITY_UPDATE fields. It applies to initial frames and later HTTP3PriorityUpdater.Update calls.
func (*HTTP3Settings) ConnectionCoalescing ΒΆ
func (h *HTTP3Settings) ConnectionCoalescing(enabled bool) *HTTP3Settings
ConnectionCoalescing permits verified HTTP/3 connections to serve additional authorities after certificate and route checks. Client/proxy ownership stays isolated. Insecure TLS, custom verification and configured client credentials keep dedicated connections. Chrome enables this; a plain client does not.
func (*HTTP3Settings) ConnectionIDGenerator ΒΆ
func (h *HTTP3Settings) ConnectionIDGenerator(generator quic.ConnectionIDGenerator) *HTTP3Settings
ConnectionIDGenerator supplies the official quic-go connection ID generator. It takes precedence over ConnectionIDLength and may generate zero-length IDs.
func (*HTTP3Settings) ConnectionIDLength ΒΆ
func (h *HTTP3Settings) ConnectionIDLength(length int) *HTTP3Settings
ConnectionIDLength sets the length of locally generated connection IDs. Valid explicit lengths are 0 through 20. Zero uses a zero-length generator and a dedicated UDP socket per connection. Unset retains quic-go's 4-byte default. This does not control the independently generated initial destination ID.
func (*HTTP3Settings) ConnectionPoolPartition ΒΆ
func (h *HTTP3Settings) ConnectionPoolPartition(partition func(context.Context, string) string) *HTTP3Settings
ConnectionPoolPartition adds an application isolation key to HTTP/3 pooling. Connections from different keys never share, even for the same authority. The callback must be concurrency safe and stable for an attempt. Nil uses the built client's network context; browser discovery partitions still apply.
func (*HTTP3Settings) ConnectionRacing ΒΆ
func (h *HTTP3Settings) ConnectionRacing(enabled bool) *HTTP3Settings
ConnectionRacing prepares HTTP/3 and a TCP backup concurrently. Requests wait for selection unless EarlyData enables an eligible bodyless GET/HEAD; then EarlyDataBackup controls whether TCP can still win before QUIC confirms. Disabled by default, independently of the selected profile's delay policy.
func (*HTTP3Settings) ConnectionRacingPolicy ΒΆ
func (h *HTTP3Settings) ConnectionRacingPolicy(policy ConnectionRacingPolicy) *HTTP3Settings
ConnectionRacingPolicy selects a delay from per-origin observations. Nil uses Surf's 100ms default. Enable separately with ConnectionRacing(true). This setter replaces any fixed delay previously selected with TCPFallbackDelay.
func (*HTTP3Settings) ControlGreaseFrames ΒΆ
func (h *HTTP3Settings) ControlGreaseFrames(frames ...HTTP3GreaseFrame) *HTTP3Settings
ControlGreaseFrames adds reserved frames after SETTINGS on every connection. Types must be 0x1f*N+0x21. Frames and payloads are copied.
func (*HTTP3Settings) ControlGreaseFramesFactory ΒΆ
func (h *HTTP3Settings) ControlGreaseFramesFactory(factory func() ([]HTTP3GreaseFrame, error)) *HTTP3Settings
ControlGreaseFramesFactory generates fresh frames once per connection. The callback must be safe for concurrent connections.
func (*HTTP3Settings) Discovery ΒΆ
func (h *HTTP3Settings) Discovery(enabled bool) *HTTP3Settings
Discovery learns HTTP/3 alternatives from authenticated Alt-Svc responses and HTTPS DNS records. Without an advertisement requests use TCP. ForceHTTP3 retains its direct-attempt behavior. Cache and failures belong to this client.
func (*HTTP3Settings) ECHClientHelloInner ΒΆ
func (h *HTTP3Settings) ECHClientHelloInner(policy utls.ECHClientHelloInnerFunc) *HTTP3Settings
ECHClientHelloInner supplies the real QUIC ECH inner ClientHello policy. Browser profiles select their policy automatically. Nil restores engine defaults.
func (*HTTP3Settings) EarlyData ΒΆ
func (h *HTTP3Settings) EarlyData(enabled bool) *HTTP3Settings
EarlyData opts bodyless GET and HEAD requests into TLS 0-RTT on resumed HTTP/3 connections. Disabled by default. Enable only when replay of these requests is acceptable; POST and requests with bodies always wait for 1-RTT. A TLS ClientSessionCache is needed to resume a connection. Standard TLS and custom browser ClientHello templates support this, including accepted ECH. Peer SETTINGS are retained with each exact ticket. A ticket without this application state still supports ordinary TLS resumption, without early data.
func (*HTTP3Settings) EarlyDataBackup ΒΆ
func (h *HTTP3Settings) EarlyDataBackup(enabled bool) *HTTP3Settings
EarlyDataBackup keeps TCP preparation active until the QUIC handshake finishes, while eligible requests can already use 0-RTT. A ready TCP backup cancels the early attempt and sends the bodyless GET/HEAD over TCP. The Firefox profile enables this policy. False selects a QUIC connection as soon as early keys are ready, following Chrome. Enable early data separately with EarlyData.
func (*HTTP3Settings) EarlyDataRestart ΒΆ
func (h *HTTP3Settings) EarlyDataRestart(enabled bool) *HTTP3Settings
EarlyDataRestart recreates HTTP/3 state on the same QUIC connection when TLS rejects 0-RTT. Requests restart once after verified TLS; rejected SETTINGS and QPACK state are discarded. It does not enable early data or replay unsafe request bodies. Firefox desktop enables this policy automatically.
func (*HTTP3Settings) EarlyRequestPolicy ΒΆ
func (h *HTTP3Settings) EarlyRequestPolicy(policy EarlyRequestPolicy) *HTTP3Settings
EarlyRequestPolicy controls whether an eligible bodyless GET/HEAD may be sent before TLS authentication. EarlyData must also be enabled. False waits for the handshake while preserving the TLS early-data offer and protocol setup. Chrome requires prior confirmed QUIC support in this client's transport; nil retains the normal EarlyData eligibility. The policy is snapshotted at Build, must return promptly and must be safe for concurrent calls.
func (*HTTP3Settings) EnableConnectProtocol ΒΆ
func (h *HTTP3Settings) EnableConnectProtocol(num uint64) *HTTP3Settings
EnableConnectProtocol enables the extended CONNECT protocol (RFC 9220).
func (*HTTP3Settings) EnableDatagrams ΒΆ
func (h *HTTP3Settings) EnableDatagrams(enabled bool) *HTTP3Settings
EnableDatagrams configures both QUIC and HTTP/3 datagram support.
func (*HTTP3Settings) EnableWebtransport ΒΆ
func (h *HTTP3Settings) EnableWebtransport(num uint64) *HTTP3Settings
EnableWebtransport advertises a WebTransport setting. It does not implement a WebTransport application protocol.
func (*HTTP3Settings) ExpireFailedAlternatives ΒΆ
func (h *HTTP3Settings) ExpireFailedAlternatives(enabled bool) *HTTP3Settings
ExpireFailedAlternatives discards a failed advertisement when its retry interval expires; a new advertisement or DNS answer is then required.
func (*HTTP3Settings) FlushEarlySettings ΒΆ
func (h *HTTP3Settings) FlushEarlySettings(enabled bool) *HTTP3Settings
FlushEarlySettings gives initial SETTINGS a send opportunity before requests use a resumed early connection. Sendable Initial CRYPTO is packetized first; pacing, congestion and flow control retain authority over packet boundaries. This does not enable early data. Chrome enables it; Firefox keeps its own initialization order. Control-frame factories must not block.
func (*HTTP3Settings) Grease ΒΆ
func (h *HTTP3Settings) Grease() *HTTP3Settings
Grease generates a fresh reserved SETTINGS identifier/value per connection. Call GreaseFactory(nil) to disable generated SETTINGS GREASE.
func (*HTTP3Settings) GreaseFactory ΒΆ
func (h *HTTP3Settings) GreaseFactory(factory func() (uint64, uint64, error)) *HTTP3Settings
GreaseFactory generates one reserved SETTINGS pair for each new HTTP/3 connection. It must be concurrency safe, return promptly and not reenter the transport. Nil disables it. Errors are returned before control-stream writes.
func (*HTTP3Settings) H3Datagram ΒΆ
func (h *HTTP3Settings) H3Datagram(num uint64) *HTTP3Settings
H3Datagram sets a custom H3_DATAGRAM value for datagram support.
func (*HTTP3Settings) HTTPSRecordsLookup ΒΆ
func (h *HTTP3Settings) HTTPSRecordsLookup(lookup HTTPSRecordsLookup) *HTTP3Settings
HTTPSRecordsLookup supplies HTTPS records from an application resolver. Nil uses the client's configured DNS transport and system resolver addresses. No public DNS provider is substituted. Proxies bypass local HTTPS discovery.
func (*HTTP3Settings) HTTPSRecordsWait ΒΆ
func (h *HTTP3Settings) HTTPSRecordsWait(policy func(time.Duration) time.Duration) *HTTP3Settings
HTTPSRecordsWait chooses the extra wait for an optional built-in HTTPS DNS query after address queries finish. Zero means no supplemental deadline. Explicit HTTPSRecordsLookup callbacks retain their own deadlines.
func (*HTTP3Settings) IgnoreIPMatching ΒΆ
func (h *HTTP3Settings) IgnoreIPMatching(enabled bool) *HTTP3Settings
IgnoreIPMatching permits a server's NOIP connection option to waive the IP check for otherwise eligible coalescing. It requires ConnectionCoalescing. Chromium 158's source default is false; advertising NOIP alone does not enable it.
func (*HTTP3Settings) MaxDataFrameSize ΒΆ
func (h *HTTP3Settings) MaxDataFrameSize(size int) *HTTP3Settings
MaxDataFrameSize caps request DATA payloads. Zero preserves one frame per body read or Write. This does not set QUIC packet boundaries.
func (*HTTP3Settings) MaxFieldSectionSize ΒΆ
func (h *HTTP3Settings) MaxFieldSectionSize(num uint64) *HTTP3Settings
MaxFieldSectionSize sets the maximum size of a field section the peer is willing to accept.
func (*HTTP3Settings) MaxResponseHeaderBytes ΒΆ
func (h *HTTP3Settings) MaxResponseHeaderBytes(limit int) *HTTP3Settings
MaxResponseHeaderBytes sets the local response header limit. Zero restores Surf's default. Use MaxFieldSectionSize separately for the advertised setting.
func (*HTTP3Settings) OnOrigin ΒΆ
func (h *HTTP3Settings) OnOrigin(callback func(*quic.Conn, []string)) *HTTP3Settings
OnOrigin observes newly learned canonical origins after a complete server ORIGIN frame. Each supplied slice belongs to the callback. It must not block or reenter the connection and may run concurrently for different connections. OriginFrames and ConnectionCoalescing must be enabled to learn origins.
func (*HTTP3Settings) OnResponseHeaders ΒΆ
func (h *HTTP3Settings) OnResponseHeaders(callback func(*http.Request, *http.Response) error) *HTTP3Settings
OnResponseHeaders observes every valid HTTP/3 response header block, including 1xx, before tracing or delivery. Returning an error aborts the request. The callback must return promptly, must not mutate either argument or read the body, and must be safe for concurrent requests. Nil removes the callback.
func (*HTTP3Settings) OriginFrameLimit ΒΆ
func (h *HTTP3Settings) OriginFrameLimit(limit int) *HTTP3Settings
OriginFrameLimit bounds distinct learned origins per connection. Zero uses 20; valid explicit limits are 1 through 65536. Invalid entries and duplicates do not consume capacity. Lowering this on a builder does not affect built clients.
func (*HTTP3Settings) OriginFrames ΒΆ
func (h *HTTP3Settings) OriginFrames(enabled bool) *HTTP3Settings
OriginFrames accepts server ORIGIN frames for connection coalescing, permitting matching destinations to skip DNS. Certificate checks still apply. It requires ConnectionCoalescing. Chrome enables it; unknown frames otherwise remain ignored.
func (*HTTP3Settings) PriorityUpdates ΒΆ
func (h *HTTP3Settings) PriorityUpdates(enabled bool) *HTTP3Settings
PriorityUpdates sends RFC 9218 control frames for explicit, nondefault request Priority headers. Independent of GREASE and local StreamPriority.
func (*HTTP3Settings) QUICConfig ΒΆ
func (h *HTTP3Settings) QUICConfig(config *quic.Config) *HTTP3Settings
QUICConfig replaces Surf's QUIC defaults with a snapshot of config. Zero-valued fields use the official quic-go defaults. Nil restores Surf's defaults. Token stores, tracers and callbacks retain their shared identity. RequireStreamCreditRelease is an advanced option for applications that manage incoming stream credit; it does not add a transport parameter to the handshake. Use Builder.QUICSettings for fluent configuration of individual options.
func (*HTTP3Settings) QpackBlockedStreams ΒΆ
func (h *HTTP3Settings) QpackBlockedStreams(num uint64) *HTTP3Settings
QpackBlockedStreams sets the maximum number of streams that can be blocked on QPACK.
func (*HTTP3Settings) QpackDrainingFraction ΒΆ
func (h *HTTP3Settings) QpackDrainingFraction(fraction float64) *HTTP3Settings
QpackDrainingFraction reserves a fraction [0,1] of the table for eviction. Old exact entries may be duplicated instead of acquiring new references.
func (*HTTP3Settings) QpackDynamicTable ΒΆ
func (h *HTTP3Settings) QpackDynamicTable(enabled bool) *HTTP3Settings
QpackDynamicTable enables request compression using the peer's dynamic table. QpackEncoderTableCapacity sets the local budget; peer SETTINGS cap that budget and the number of streams that may reference unacknowledged insertions.
func (*HTTP3Settings) QpackEagerStreamTypes ΒΆ
func (h *HTTP3Settings) QpackEagerStreamTypes(eager bool) *HTTP3Settings
QpackEagerStreamTypes queues stream type bytes at initialization for streams listed in QpackStreamOrder. False sends each type with its first instruction.
func (*HTTP3Settings) QpackEncoderCapacityRequiresSetting ΒΆ
func (h *HTTP3Settings) QpackEncoderCapacityRequiresSetting(enabled bool) *HTTP3Settings
QpackEncoderCapacityRequiresSetting keeps an omitted peer capacity distinct from an explicit zero. Zero announcements still use QpackEncoderZeroCapacity.
func (*HTTP3Settings) QpackEncoderCapacityTiming ΒΆ
func (h *HTTP3Settings) QpackEncoderCapacityTiming(timing QPACKCapacityTiming) *HTTP3Settings
QpackEncoderCapacityTiming queues capacity after peer SETTINGS or when encoding the next outgoing HEADERS block. It does not wait for server SETTINGS or force network delivery order between independent QUIC streams.
func (*HTTP3Settings) QpackEncoderTableCapacity ΒΆ
func (h *HTTP3Settings) QpackEncoderTableCapacity(capacity uint64) *HTTP3Settings
QpackEncoderTableCapacity limits the capacity announced for request encoding. The announcement is capped by peer SETTINGS. Dynamic request compression also requires QpackDynamicTable(true). QpackMaxTableCapacity separately configures the receive-side dynamic table advertised in our own SETTINGS.
func (*HTTP3Settings) QpackEncoderZeroCapacity ΒΆ
func (h *HTTP3Settings) QpackEncoderZeroCapacity(enabled bool) *HTTP3Settings
QpackEncoderZeroCapacity sends an explicit zero capacity instruction when the peer offers no dynamic table, initializing an otherwise lazy encoder stream.
func (*HTTP3Settings) QpackHuffman ΒΆ
func (h *HTTP3Settings) QpackHuffman(mode QPACKHuffmanMode) *HTTP3Settings
QpackHuffman selects native/always, strictly shorter, or raw string encoding.
func (*HTTP3Settings) QpackIndexing ΒΆ
func (h *HTTP3Settings) QpackIndexing(mode QPACKIndexingMode) *HTTP3Settings
QpackIndexing selects insertion of all eligible fields, only new names, or no new entries. Existing dynamic entries remain usable unless never indexed.
func (*HTTP3Settings) QpackIndexingPolicy ΒΆ
func (h *HTTP3Settings) QpackIndexingPolicy(policy func(name, value string) bool) *HTTP3Settings
QpackIndexingPolicy optionally filters new insertions by lowercase name/value. The callback may run concurrently on different connections and must not reenter the transport. Nil removes the filter. Never-index fields are always excluded.
func (*HTTP3Settings) QpackLiteralInsertNames ΒΆ
func (h *HTTP3Settings) QpackLiteralInsertNames(enabled bool) *HTTP3Settings
QpackLiteralInsertNames sends names literally in Insert instructions instead of referencing existing static/dynamic names.
func (*HTTP3Settings) QpackMaxTableCapacity ΒΆ
func (h *HTTP3Settings) QpackMaxTableCapacity(num uint64) *HTTP3Settings
QpackMaxTableCapacity sets the advertised and enforced receive-side QPACK dynamic table capacity. Zero selects the static-only decoder.
func (*HTTP3Settings) QpackMaxTrackedSections ΒΆ
func (h *HTTP3Settings) QpackMaxTrackedSections(limit uint64) *HTTP3Settings
QpackMaxTrackedSections bounds outstanding dynamic header/trailer sections. At the bound new sections use static encoding. Zero selects the default 4096.
func (*HTTP3Settings) QpackNeverIndex ΒΆ
func (h *HTTP3Settings) QpackNeverIndex(names ...string) *HTTP3Settings
QpackNeverIndex selects fields to encode as literals with QPACK's N bit. Names are copied and normalized. An empty list restores upstream encoding.
func (*HTTP3Settings) QpackPostBaseReferences ΒΆ
func (h *HTTP3Settings) QpackPostBaseReferences(enabled bool) *HTTP3Settings
QpackPostBaseReferences fixes Base before a section's insertions, allowing post-base references. False selects Base equal to Required Insert Count.
func (*HTTP3Settings) QpackResumptionErrorCode ΒΆ
func (h *HTTP3Settings) QpackResumptionErrorCode(policy func(previous, current uint64) http3.ErrCode) *HTTP3Settings
QpackResumptionErrorCode selects the close code for an incompatible nonzero table capacity after accepted 0-RTT. Browser profiles configure their source policy. Nil or a zero result keeps the RFC 9204 decoder-stream error. The callback may run concurrently on different connections and must not do I/O.
func (*HTTP3Settings) QpackSplitCookies ΒΆ
func (h *HTTP3Settings) QpackSplitCookies(enabled bool) *HTTP3Settings
QpackSplitCookies emits one cookie field per nonempty cookie-pair on HTTP/3. Field order and the caller's original headers are preserved.
func (*HTTP3Settings) QpackStopOnInsertionFailure ΒΆ
func (h *HTTP3Settings) QpackStopOnInsertionFailure(enabled bool) *HTTP3Settings
QpackStopOnInsertionFailure stops new insertion attempts for the rest of a section after the first entry cannot fit. Existing references remain usable.
func (*HTTP3Settings) QpackStreamOrder ΒΆ
func (h *HTTP3Settings) QpackStreamOrder(order ...QPACKStreamType) *HTTP3Settings
QpackStreamOrder reserves QPACK streams after the control stream in the given order, while peer credit permits. Omitted streams open on demand. Input is copied.
func (*HTTP3Settings) RequestBodyBufferSize ΒΆ
func (h *HTTP3Settings) RequestBodyBufferSize(size int) *HTTP3Settings
RequestBodyBufferSize sets reads from HTTP/3 request bodies (0 uses 8 KiB). It clears previously configured size and first-read policies. Sizes must be in [0, 16 MiB].
func (*HTTP3Settings) RequestBodyBufferSizePolicy ΒΆ
func (h *HTTP3Settings) RequestBodyBufferSizePolicy(policy func(int64) int) *HTTP3Settings
RequestBodyBufferSizePolicy chooses a buffer using ContentLength (-1 when unknown). It must be concurrency safe; zero uses 8 KiB. Nil restores the fixed size.
func (*HTTP3Settings) RequestBodyFirstReadSizePolicy ΒΆ
func (h *HTTP3Settings) RequestBodyFirstReadSizePolicy(policy func(HTTP3RequestBodyReadInfo) int) *HTTP3Settings
RequestBodyFirstReadSizePolicy caps the first nonempty HTTP/3 body read. Zero restores the normal buffer size; a positive result must not exceed it. The callback receives actual outgoing fields, including implicit headers, and runs before request bytes or QPACK state changes. It must be concurrency safe. Nil clears this policy. It does not change QUIC packet boundaries.
func (*HTTP3Settings) RequestGreaseFrames ΒΆ
func (h *HTTP3Settings) RequestGreaseFrames(frames ...HTTP3GreaseFrame) *HTTP3Settings
RequestGreaseFrames adds reserved frames before each request's HEADERS. Types must be 0x1f*N+0x21. Frames and payloads are copied.
func (*HTTP3Settings) RequestGreaseFramesFactory ΒΆ
func (h *HTTP3Settings) RequestGreaseFramesFactory( factory func(*http.Request) ([]HTTP3GreaseFrame, error), ) *HTTP3Settings
RequestGreaseFramesFactory generates frames for each request. The callback must be safe for concurrent connections and must not mutate the request.
func (*HTTP3Settings) Set ΒΆ
func (h *HTTP3Settings) Set() *Builder
Set applies the configured HTTP/3 settings to the client's transport.
func (*HTTP3Settings) SettingsH3Datagram ΒΆ
func (h *HTTP3Settings) SettingsH3Datagram(num uint64) *HTTP3Settings
SettingsH3Datagram sets the H3_DATAGRAM setting value.
func (*HTTP3Settings) StreamPriority ΒΆ
func (h *HTTP3Settings) StreamPriority(urgency int8, incremental bool) *HTTP3Settings
StreamPriority sets local QUIC scheduling for request data. Urgency is clipped to 0 through 7 by quic-go. This does not send a PRIORITY_UPDATE frame or set the HTTP Priority header. StreamSchedulingByCreation takes precedence when enabled; disable it through QUICSettings to select urgency-based scheduling.
func (*HTTP3Settings) TCPFallbackAfterQUICStart ΒΆ
func (h *HTTP3Settings) TCPFallbackAfterQUICStart(enabled bool) *HTTP3Settings
TCPFallbackAfterQUICStart starts the backup delay after DNS/socket preparation and initialization of the shared QUIC attempt. A reusable H2 session, or an existing TCP group for DNS-only H3 discovery, bypasses that initialization hold. A configured delay still applies. False starts the timer with request preparation. Chrome enables this policy. TCPFallbackDelay selects the original request-start timing; call this method afterward to combine a fixed delay with QUIC-start timing.
func (*HTTP3Settings) TCPFallbackDelay ΒΆ
func (h *HTTP3Settings) TCPFallbackDelay(delay time.Duration) *HTTP3Settings
TCPFallbackDelay replaces the profile's policy with a fixed nonnegative delay. Zero starts both handshakes immediately. Enable with ConnectionRacing(true).
type HTTPSRecord ΒΆ
type HTTPSRecord struct {
Priority uint16
Target string
ALPN []string
Port uint16
IPv4Hint, IPv6Hint []netip.Addr
TTL time.Duration
ECH []byte
Mandatory []uint16
NoDefaultALPN bool
}
HTTPSRecord describes an RFC 9460 HTTPS service binding. Lookup callbacks must return resolved ServiceMode bindings with owned slices and honor cancellation. The built-in resolver follows CNAME/AliasMode chains.
type HTTPSRecordsLookup ΒΆ
type HTTPSRecordsLookup func(context.Context, string) ([]HTTPSRecord, error)
type Headers ΒΆ
type Headers http.Header
Headers represents a collection of HTTP Headers.
func (Headers) Contains ΒΆ
Contains checks if the header contains any of the specified patterns. It accepts a header name and a pattern (or list of patterns) and returns a boolean value indicating whether any of the patterns are found in the header values. The patterns can be a string, a slice of strings, or a slice of *regexp.Regexp.
func (Headers) Del ΒΆ
func (h Headers) Del(key g.String)
Del deletes the values associated with a specified header key. It wraps the Del method from the textproto.MIMEHeader type.
type Impersonate ΒΆ
type Impersonate struct {
// contains filtered or unexported fields
}
func (*Impersonate) Android ΒΆ
func (im *Impersonate) Android() *Impersonate
Android sets the OS to Android.
func (*Impersonate) Chrome ΒΆ
func (im *Impersonate) Chrome() *Builder
Chrome impersonates Chrome 158 on desktop/Android and its separate iOS profile.
func (*Impersonate) Firefox ΒΆ
func (im *Impersonate) Firefox() *Builder
Firefox impersonates Firefox 160 on desktop and the existing mobile profiles.
func (*Impersonate) Linux ΒΆ
func (im *Impersonate) Linux() *Impersonate
Linux sets the OS to Linux.
func (*Impersonate) MacOS ΒΆ
func (im *Impersonate) MacOS() *Impersonate
MacOS sets the OS to macOS.
func (*Impersonate) RandomOS ΒΆ
func (im *Impersonate) RandomOS() *Impersonate
RandomOS selects a random OS (Windows, macOS, Linux, Android, or iOS) for the impersonate.
func (*Impersonate) Windows ΒΆ
func (im *Impersonate) Windows() *Impersonate
Windows sets the OS to Windows.
type InitialCryptoLayoutInfo ΒΆ
type InitialCryptoLayoutInfo = quic.InitialCryptoLayoutInfo
InitialCryptoLayoutInfo supplies the ClientHello boundaries and live Initial packet budgets to an InitialCryptoLayout policy.
type JA ΒΆ
type JA struct {
// contains filtered or unexported fields
}
JA provides JA3/4 TLS fingerprinting capabilities for HTTP clients. JA is a method for creating SSL/TLS client fingerprints to identify and classify malware or other applications. This struct allows configuring various TLS ClientHello specifications to mimic different browsers and applications for advanced HTTP client behavior.
Reference: https://lwthiker.com/networks/2022/06/17/tls-fingerprinting.html
func (*JA) Chrome158 ΒΆ
Chrome158 applies the current Chrome TLS template with per-connection extension shuffling and the browser's ECH inner and session-cache policies.
func (*JA) CloseNotify ΒΆ
CloseNotify overrides sending a TLS close_notify alert on Close for JA-owned TCP connections. Chrome omits it; Firefox sends it. This does not change QUIC or explicit TLS half-closes. Chain before a terminal JA method.
func (*JA) DynamicRecordSizing ΒΆ
DynamicRecordSizing overrides adaptive TLS record sizing for JA-owned TCP connections. Browser defaults apply first. Chain before SetHelloSpec, SetHelloID or a terminal browser method such as Chrome or Firefox.
func (*JA) ECHClientHelloInner ΒΆ
func (j *JA) ECHClientHelloInner(policy utls.ECHClientHelloInnerFunc) *JA
ECHClientHelloInner supplies the real encrypted inner ClientHello policy. Chain before SetHelloSpec or SetHelloID. Nil restores the engine default.
func (*JA) Firefox102 ΒΆ
Firefox102 sets the JA3/4 fingerprint to mimic Firefox version 102.
func (*JA) Firefox105 ΒΆ
Firefox105 sets the JA3/4 fingerprint to mimic Firefox version 105.
func (*JA) Firefox120 ΒΆ
Firefox120 sets the JA3/4 fingerprint to mimic Firefox version 120.
func (*JA) Firefox148 ΒΆ
Firefox148 sets the JA3/4 fingerprint to mimic Firefox version 148.
func (*JA) Firefox160 ΒΆ
Firefox160 sets the current Firefox 160 desktop TLS fingerprint.
func (*JA) IOS ΒΆ
IOS sets the JA3/4 fingerprint to mimic the latest iOS Safari browser (auto-detection).
func (*JA) KeepAlivePolicy ΒΆ
func (j *JA) KeepAlivePolicy( policy func(TCPKeepAliveInfo) TCPKeepAliveOptions, ) *JA
KeepAlivePolicy overrides browser TCP keepalive on Surf-owned dial functions. Chain before a terminal JA method. Nil preserves net.Dialer settings. Explicit custom DialContext and net.Dialer keepalive settings remain application-owned. The callback must return promptly, be concurrency safe and never reenter the client. Reusing HTTP/1 restarts its transition; closing cancels it. QUIC does not use TCP keepalive.
func (*JA) Randomized ΒΆ
Randomized sets a completely randomized JA3/4 fingerprint.
func (*JA) RandomizedALPN ΒΆ
RandomizedALPN sets a randomized JA3/4 fingerprint with ALPN (Application-Layer Protocol Negotiation).
func (*JA) RandomizedNoALPN ΒΆ
RandomizedNoALPN sets a randomized JA3/4 fingerprint without ALPN.
func (*JA) Safari ΒΆ
Safari sets the JA3/4 fingerprint to mimic the latest Safari browser (auto-detection).
func (*JA) Safari26_3 ΒΆ
Safari26_3 sets the TLS fingerprint to Safari 26.3 (also used by Chrome on iOS).
func (*JA) SetHelloID ΒΆ
func (j *JA) SetHelloID(id utls.ClientHelloID) *Builder
SetHelloID sets a ClientHelloID for the TLS connection.
The provided ClientHelloID is used to customize the TLS handshake. This should be a valid identifier that can be mapped to a specific ClientHelloSpec.
It returns a pointer to the Options struct for method chaining. This allows additional configuration methods to be called on the result.
Example usage:
JA().SetHelloID(utls.HelloChrome_Auto)
func (*JA) SetHelloSpec ΒΆ
func (j *JA) SetHelloSpec(spec utls.ClientHelloSpec) *Builder
SetHelloSpec sets a custom ClientHelloSpec for the TLS connection.
This method allows you to set a custom ClientHelloSpec to be used during the TLS handshake. The provided spec should be a valid ClientHelloSpec.
It returns a pointer to the Options struct for method chaining. This allows additional configuration methods to be called on the result.
Example usage:
JA().SetHelloSpec(spec)
func (*JA) ShuffleExtensions ΒΆ
ShuffleExtensions enables Chromium's per-connection ClientHello extension shuffle: the extension order is randomized on every TLS handshake instead of staying fixed for the lifetime of the client. GREASE, padding and pre_shared_key keep their positions, as they are positionally invariant on the wire.
Chromium shuffles since v110, so a custom Chrome-derived spec needs this to stay consistent with the User-Agent it claims. Firefox keeps a fixed order β do not enable it there.
Unlike SetHelloID / SetHelloSpec this method is not terminal: it returns the JA struct, so it has to be chained before the spec is set.
Example usage:
JA().ShuffleExtensions().SetHelloSpec(spec)
type Multipart ΒΆ
type Multipart struct {
// contains filtered or unexported fields
}
Multipart represents multipart form data with fields and files.
func NewMultipart ΒΆ
func NewMultipart() *Multipart
NewMultipart creates a new empty Multipart object.
func (*Multipart) ContentType ΒΆ
ContentType sets the content type for the last added file. Must be called immediately after File/FileReader/FileString/FileBytes.
func (*Multipart) FileName ΒΆ
FileName overrides the filename for the last added file. Useful when you want a different name than the physical file.
func (*Multipart) FileReader ΒΆ
FileReader adds a file from io.Reader to the multipart.
func (*Multipart) FileString ΒΆ
FileString adds a file from string content to the multipart.
func (*Multipart) Retry ΒΆ
Retry controls whether the multipart body should be buffered in memory to support retries on status codes (429, 503, 5xx, etc.).
When set, the body is fully read into memory before sending, allowing the client to replay it on retry.
Recommended only for small requests (β€ 5β10 MB).
type MultipartFile ΒΆ
type MultipartFile struct {
// contains filtered or unexported fields
}
MultipartFile represents a single file for multipart upload.
type NetworkChangeAction ΒΆ
type NetworkChangeAction = profiles.NetworkChangeAction
NetworkChangeAction selects maintenance on existing connection pools.
type NetworkChangeInfo ΒΆ
type NetworkChangeInfo = profiles.NetworkChangeInfo
NetworkChangeInfo describes an address, link, route or local identity change.
type NetworkChangePolicy ΒΆ
type NetworkChangePolicy = profiles.NetworkChangePolicy
NetworkChangePolicy selects pool maintenance for a network notification.
type NetworkSettings ΒΆ
type NetworkSettings struct {
// contains filtered or unexported fields
}
NetworkSettings configures native network notifications through the client builder. Browser defaults apply first; explicit overrides apply last.
func (*NetworkSettings) Automatic ΒΆ
func (n *NetworkSettings) Automatic(enabled bool) *NetworkSettings
Automatic enables native notifications. False leaves explicit NetworkChanged calls available, for applications that already own network notifications.
func (*NetworkSettings) CoalescingDelay ΒΆ
func (n *NetworkSettings) CoalescingDelay(delay time.Duration) *NetworkSettings
CoalescingDelay merges native notifications from the first event without extending the window. Valid values are zero through one minute.
func (*NetworkSettings) Identity ΒΆ
func (n *NetworkSettings) Identity(reader func([]netip.Addr) (string, error)) *NetworkSettings
Identity sets the native network identity reader. Nil disables it. A nil input requests a full refresh; other inputs identify neighbors acquiring a MAC. The first successful value is a baseline; later changes set IdentityChanged. Errors retain that baseline. The callback must return promptly, be safe across clients and not reenter the client. Identity values remain local.
func (*NetworkSettings) Policy ΒΆ
func (n *NetworkSettings) Policy(policy NetworkChangePolicy) *NetworkSettings
Policy selects maintenance for each event. Nil disables maintenance. The callback must return promptly, be concurrency safe and not reenter this client.
func (*NetworkSettings) Set ΒΆ
func (n *NetworkSettings) Set() *Builder
Set returns to the client builder.
type PacingAlgorithm ΒΆ
type PacingAlgorithm = quic.PacingAlgorithm
type PeerAckFrequency ΒΆ
type PeerAckFrequency = quic.PeerAckFrequency
type PeerAckFrequencyInfo ΒΆ
type PeerAckFrequencyInfo = quic.PeerAckFrequencyInfo
type PeerAckFrequencyPolicy ΒΆ
type PeerAckFrequencyPolicy = quic.PeerAckFrequencyPolicy
type PeerPacketInfo ΒΆ
type PeerPacketInfo = quic.PeerPacketInfo
PeerPacketInfo describes a routed packet whose keys are unavailable.
type PeerPacketRecovery ΒΆ
type PeerPacketRecovery = quic.PeerPacketRecovery
PeerPacketRecovery selects transport responses without accepting the packet.
type QPACKCapacityTiming ΒΆ
type QPACKCapacityTiming = http3.QPACKCapacityTiming
QPACKCapacityTiming controls when an outgoing capacity instruction is queued.
type QPACKHuffmanMode ΒΆ
type QPACKHuffmanMode = http3.QPACKHuffmanMode
type QPACKIndexingMode ΒΆ
type QPACKIndexingMode = http3.QPACKIndexingMode
type QPACKStreamType ΒΆ
type QPACKStreamType = http3.QPACKStreamType
QPACKStreamType identifies an HTTP/3 QPACK unidirectional stream.
type QUICSettings ΒΆ
type QUICSettings struct {
// contains filtered or unexported fields
}
QUICSettings configures the HTTP/3 transport through Surf's fluent API. Each setter changes only its own option, retaining the selected browser profile. Set returns the main Builder; ForceHTTP3 selects use of this transport.
func (*QUICSettings) AckDecimation ΒΆ
func (q *QUICSettings) AckDecimation(after, threshold uint64) *QUICSettings
AckDecimation selects a new packet threshold once the received packet number reaches the smallest received number plus after. It is not a received-packet count. A zero threshold disables decimation without negotiating ACK_FREQUENCY.
func (*QUICSettings) AckDelayRTTDivisor ΒΆ
func (q *QUICSettings) AckDelayRTTDivisor(divisor uint32) *QUICSettings
AckDelayRTTDivisor caps delayed ACKs by minRTT/divisor after decimation. Zero disables RTT scaling. MaxAckDelay still supplies the upper bound.
func (*QUICSettings) AckECN ΒΆ
func (q *QUICSettings) AckECN(mode AckECNMode) *QUICSettings
AckECN selects immediate ACKs for CE marks, CE transitions, or counting only.
func (*QUICSettings) AckFlushOnPacket ΒΆ
func (q *QUICSettings) AckFlushOnPacket(enabled bool) *QUICSettings
AckFlushOnPacket gives a queued ACK a send opportunity before the next received UDP datagram. Chrome enables this; Firefox retains receive batching. Socket backpressure can still delay the actual transmission.
func (*QUICSettings) AckMissingPacketLimit ΒΆ
func (q *QUICSettings) AckMissingPacketLimit(packets uint64) *QUICSettings
AckMissingPacketLimit bounds immediate ACKs following a gap in Window mode.
func (*QUICSettings) AckOnlyMaxDataThreshold ΒΆ
func (q *QUICSettings) AckOnlyMaxDataThreshold(threshold int) *QUICSettings
AckOnlyMaxDataThreshold solicits acknowledgment by repeating current MAX_DATA after a run of ACK-only packets. It grants no extra credit and replaces the periodic PING policy. Zero clears this policy; PTO probes remain independent.
func (*QUICSettings) AckOnlyPingThreshold ΒΆ
func (q *QUICSettings) AckOnlyPingThreshold(threshold int) *QUICSettings
AckOnlyPingThreshold controls extra PINGs after consecutive ACK-only packets. Zero retains native behavior; -1 disables these PINGs, preserving PTO probes.
func (*QUICSettings) AckPacketThreshold ΒΆ
func (q *QUICSettings) AckPacketThreshold(packets uint64) *QUICSettings
AckPacketThreshold sets the initial number of ack-eliciting packets per ACK. Zero uses the engine's native threshold. Only Application Data is affected.
func (*QUICSettings) AckProbePolicy ΒΆ
func (q *QUICSettings) AckProbePolicy(policy func(quic.AckProbeInfo) bool) *QUICSettings
AckProbePolicy replaces periodic ACK-only probes with a decision based on recovery state. It runs in the send loop and must not block or reenter the connection. Nil disables this callback. PTO recovery remains independent.
func (*QUICSettings) AckReordering ΒΆ
func (q *QUICSettings) AckReordering(mode AckReorderingMode) *QUICSettings
AckReordering selects how missing/out-of-order packets prompt ACKs.
func (*QUICSettings) ActiveConnectionIDLimit ΒΆ
func (q *QUICSettings) ActiveConnectionIDLimit(limit uint64) *QUICSettings
ActiveConnectionIDLimit sets the receive-side connection ID limit (at least 2). Zero selects quic-go's default.
func (*QUICSettings) AddressFallbackDelay ΒΆ
func (q *QUICSettings) AddressFallbackDelay(delay time.Duration) *QUICSettings
AddressFallbackDelay enables staggered QUIC attempts to resolved addresses. Zero preserves serial address attempts. Positive values require 1-RTT.
func (*QUICSettings) AllowConnectionWindowIncrease ΒΆ
func (q *QUICSettings) AllowConnectionWindowIncrease(allow func(*quic.Conn, uint64) bool) *QUICSettings
AllowConnectionWindowIncrease decides whether automatic receive window growth is permitted. The callback must not call connection or stream methods.
func (*QUICSettings) ApplicationProbePackets ΒΆ
func (q *QUICSettings) ApplicationProbePackets(count uint8) *QUICSettings
ApplicationProbePackets sets the 1-RTT PTO allowance (0..2). Zero preserves the native allowance. It does not change random number skipping.
func (*QUICSettings) ApplicationProbeSkipPacketNumber ΒΆ
func (q *QUICSettings) ApplicationProbeSkipPacketNumber(enabled bool) *QUICSettings
ApplicationProbeSkipPacketNumber controls the 1-RTT PTO gap independently of random PacketNumberSkipping. It overrides that setting for PTO only. Browser profiles select their explicit policy; native configs retain the legacy coupling.
func (*QUICSettings) CachedInitialRTT ΒΆ
func (q *QUICSettings) CachedInitialRTT(parameter uint64, minimum, maximum time.Duration) *QUICSettings
CachedInitialRTT learns measured RTT from this client's preceding direct connection to each origin. It owns parameter and encodes the measured RTT in microseconds; an empty history omits it. Local recovery uses the same estimate clamped to minimum..maximum. Proxy connections do not share this history. Parameter zero disables it. Bounds must be positive and ordered when enabled.
func (*QUICSettings) ClientHelloFactory ΒΆ
func (q *QUICSettings) ClientHelloFactory(factory func() (utls.ClientHelloSpec, error)) *QUICSettings
ClientHelloFactory supplies a fresh QUIC TLS template per connection attempt. It may run concurrently; templates must not share mutable extensions.
func (*QUICSettings) ClientHelloSpec ΒΆ
func (q *QUICSettings) ClientHelloSpec(spec *utls.ClientHelloSpec) *QUICSettings
ClientHelloSpec snapshots an explicit QUIC TLS template. Nil restores standard TLS.
func (*QUICSettings) CoalescePTOProbes ΒΆ
func (q *QUICSettings) CoalescePTOProbes(enabled bool) *QUICSettings
CoalescePTOProbes shares one datagram budget across eligible encryption spaces. It retains crypto PTO baselines and suppresses empty crypto follow-up probes; queued data can still be sent in every space. Firefox enables this policy.
func (*QUICSettings) CoalesceSmallEarlyPackets ΒΆ
func (q *QUICSettings) CoalesceSmallEarlyPackets(enabled bool) *QUICSettings
CoalesceSmallEarlyPackets lets 0-RTT use a datagram remainder below Go's ordinary coalescing threshold when a protected packet fits. Firefox enables this; other encryption spaces retain their usual threshold.
func (*QUICSettings) CompatibleVersionNegotiation ΒΆ
func (q *QUICSettings) CompatibleVersionNegotiation(enabled bool) *QUICSettings
CompatibleVersionNegotiation enables authenticated v1/v2 switching within a handshake (RFC 9368/9369). Versions lists the permitted versions; a custom transport-parameter layout can select their preference and GREASE ordering. Firefox enables this mechanism by default. Native clients keep it disabled.
func (*QUICSettings) CongestionControl ΒΆ
func (q *QUICSettings) CongestionControl(algorithm CongestionControlAlgorithm) *QUICSettings
CongestionControl selects Reno, RFC 9438 CUBIC, or fixed-point byte-mode CUBIC. Native restores the engine default. Pacing and loss detection are separate.
func (*QUICSettings) CongestionControlConnections ΒΆ
func (q *QUICSettings) CongestionControlConnections(count uint32) *QUICSettings
CongestionControlConnections sets the number of emulated byte-mode CUBIC connections (1..16). Zero means one; other algorithms allow only zero or one.
func (*QUICSettings) CongestionControlSegmentSize ΒΆ
func (q *QUICSettings) CongestionControlSegmentSize(bytes uint16) *QUICSettings
CongestionControlSegmentSize fixes the accounting segment independently of UDP packet size. Zero follows the path MTU; explicit values are 1200..65527.
func (*QUICSettings) ConnectionIDGenerator ΒΆ
func (q *QUICSettings) ConnectionIDGenerator(generator quic.ConnectionIDGenerator) *QUICSettings
ConnectionIDGenerator sets a custom generator, taking precedence over length.
func (*QUICSettings) ConnectionIDLength ΒΆ
func (q *QUICSettings) ConnectionIDLength(length int) *QUICSettings
ConnectionIDLength sets the local connection ID length, from 0 through 20. Zero uses a dedicated UDP socket for each connection.
func (*QUICSettings) DisableClientHelloScrambling ΒΆ
func (q *QUICSettings) DisableClientHelloScrambling(disabled bool) *QUICSettings
DisableClientHelloScrambling controls SNI/ECH CRYPTO fragmentation.
func (*QUICSettings) DisableConnectionIDRotation ΒΆ
func (q *QUICSettings) DisableConnectionIDRotation(disable bool) *QUICSettings
DisableConnectionIDRotation keeps the active ID on an unchanged path. Peer retirement and connection migration continue to replace IDs as needed.
func (*QUICSettings) DisablePathMTUDiscovery ΒΆ
func (q *QUICSettings) DisablePathMTUDiscovery(disabled bool) *QUICSettings
DisablePathMTUDiscovery controls whether QUIC probes for a larger path MTU.
func (*QUICSettings) DisableTransportParameterGrease ΒΆ
func (q *QUICSettings) DisableTransportParameterGrease(disabled bool) *QUICSettings
DisableTransportParameterGrease controls reserved transport parameters, including those supplied by a browser factory. False uses native QUIC GREASE.
func (*QUICSettings) ECHClientHelloInner ΒΆ
func (q *QUICSettings) ECHClientHelloInner(policy utls.ECHClientHelloInnerFunc) *QUICSettings
ECHClientHelloInner supplies the real QUIC ECH inner ClientHello policy.
func (*QUICSettings) EarlyDataResendOnPeerCrypto ΒΆ
func (q *QUICSettings) EarlyDataResendOnPeerCrypto(enabled bool) *QUICSettings
EarlyDataResendOnPeerCrypto repeats outstanding 0-RTT recovery tokens when authenticated Initial CRYPTO makes no TLS progress. The first Application ACK ends this mechanism. PING alone never repeats early STREAM data.
func (*QUICSettings) EnableDatagrams ΒΆ
func (q *QUICSettings) EnableDatagrams(enabled bool) *QUICSettings
EnableDatagrams configures both QUIC and HTTP/3 datagram support.
func (*QUICSettings) EnableStreamResetPartialDelivery ΒΆ
func (q *QUICSettings) EnableStreamResetPartialDelivery(enabled bool) *QUICSettings
EnableStreamResetPartialDelivery controls reliable stream resets.
func (*QUICSettings) FlushEarlyData ΒΆ
func (q *QUICSettings) FlushEarlyData(enabled bool) *QUICSettings
FlushEarlyData gives sendable Initial data and the early-ready callback's staged data separate send opportunities before releasing the connection. False permits coalescing with Initial; pacing and congestion still apply. HTTP/3's FlushEarlySettings enables this for its control-stream initialization.
func (*QUICSettings) HandshakeAckBeforeData ΒΆ
func (q *QUICSettings) HandshakeAckBeforeData(enabled bool) *QUICSettings
HandshakeAckBeforeData separates queued handshake ACKs from the first local Handshake CRYPTO flight without adding a timer or changing TLS verification.
func (*QUICSettings) HandshakeCryptoRecovery ΒΆ
func (q *QUICSettings) HandshakeCryptoRecovery(enabled bool) *QUICSettings
HandshakeCryptoRecovery tracks Handshake CRYPTO ranges and late original PTO ACKs. Disabling also removes its peer-probe retransmission policy.
func (*QUICSettings) HandshakeCryptoResendOnPeerProbe ΒΆ
func (q *QUICSettings) HandshakeCryptoResendOnPeerProbe(enabled bool) *QUICSettings
HandshakeCryptoResendOnPeerProbe resends unacknowledged Handshake CRYPTO on PING or non-progressing CRYPTO. Enabling also selects Handshake recovery.
func (*QUICSettings) HandshakeIdleTimeout ΒΆ
func (q *QUICSettings) HandshakeIdleTimeout(timeout time.Duration) *QUICSettings
HandshakeIdleTimeout sets the idle timeout during connection establishment. Zero selects quic-go's default.
func (*QUICSettings) HandshakeProbeOnlyWithData ΒΆ
func (q *QUICSettings) HandshakeProbeOnlyWithData(enabled bool) *QUICSettings
HandshakeProbeOnlyWithData suppresses empty follow-up Handshake probes. The first probe can still send PING; queued CRYPTO uses the full allowance.
func (*QUICSettings) HandshakeProbePackets ΒΆ
func (q *QUICSettings) HandshakeProbePackets(count uint8) *QUICSettings
HandshakeProbePackets sets the Handshake PTO allowance (0..2). Zero preserves the native allowance; the selected profile supplies its default.
func (*QUICSettings) HandshakeProbeSkipPacketNumber ΒΆ
func (q *QUICSettings) HandshakeProbeSkipPacketNumber(enabled bool) *QUICSettings
HandshakeProbeSkipPacketNumber controls a deliberate Handshake PTO number gap.
func (*QUICSettings) ImmediateACKOnPeerPing ΒΆ
func (q *QUICSettings) ImmediateACKOnPeerPing(enabled bool) *QUICSettings
ImmediateACKOnPeerPing selects immediate acknowledgment of a verified 1-RTT PING. Other application packets retain the configured ACK policy.
func (*QUICSettings) InitialACKResetsPTO ΒΆ
func (q *QUICSettings) InitialACKResetsPTO(enabled bool) *QUICSettings
InitialACKResetsPTO resets probe-timeout backoff on a new Initial ACK before peer address validation completes. Firefox selects this recovery policy.
func (*QUICSettings) InitialCongestionWindowPackets ΒΆ
func (q *QUICSettings) InitialCongestionWindowPackets(packets uint32) *QUICSettings
InitialCongestionWindowPackets sets the initial send window in datagram-sized packets (path MTU unless CongestionControlSegmentSize is fixed). Zero restores the engine default; supported explicit values are 2..10000.
func (*QUICSettings) InitialConnectionReceiveWindow ΒΆ
func (q *QUICSettings) InitialConnectionReceiveWindow(size uint64) *QUICSettings
InitialConnectionReceiveWindow sets the initial connection receive window.
func (*QUICSettings) InitialCryptoCoalescingBarrier ΒΆ
func (q *QUICSettings) InitialCryptoCoalescingBarrier(enabled bool) *QUICSettings
InitialCryptoCoalescingBarrier keeps later packet spaces out of an Initial datagram while Initial CRYPTO remains queued. It permits coalescing with the final Initial and does not wait for an ACK or handshake confirmation.
func (*QUICSettings) InitialCryptoFirstFrameSize ΒΆ
func (q *QUICSettings) InitialCryptoFirstFrameSize(min, max int) *QUICSettings
InitialCryptoFirstFrameSize selects a prefix size for cross-packet protection. A first packet carries that prefix and trailing ClientHello bytes, with the middle in following packets. Zero disables this layout. Bounds are 0..16384.
func (*QUICSettings) InitialCryptoFrameSplits ΒΆ
func (q *QUICSettings) InitialCryptoFrameSplits(min, max int) *QUICSettings
InitialCryptoFrameSplits sets an inclusive range of random split attempts per padded client Initial. Available padding bounds the actual number of splits.
func (*QUICSettings) InitialCryptoLayout ΒΆ
func (q *QUICSettings) InitialCryptoLayout(policy func(InitialCryptoLayoutInfo) [][]CryptoRange) *QUICSettings
InitialCryptoLayout chooses ordered ranges of the first ClientHello for each Initial packet from its SNI/ECH positions, unsent ranges and live packet budget. Each result must cover Remaining exactly once; invalid layouts fail before sending. The engine sends the first group and reconsiders the remaining bytes with the next packet's actual budget. Nil retains native preparation. The policy must support concurrent calls and return promptly. Later Initial data, including a HelloRetryRequest response, keeps normal stream ordering.
func (*QUICSettings) InitialCryptoProbePackets ΒΆ
func (q *QUICSettings) InitialCryptoProbePackets(count uint8) *QUICSettings
InitialCryptoProbePackets sets the Initial PTO allowance and preparation batch. Zero keeps the native allowance and a one-packet batch; valid counts are 0..2. A nonzero count enables byte-range recovery and original-packet ACK tracking.
func (*QUICSettings) InitialCryptoRecovery ΒΆ
func (q *QUICSettings) InitialCryptoRecovery(enabled bool) *QUICSettings
InitialCryptoRecovery tracks lost Initial bytes independently of their old frame boundaries and retires them when a packet copy is acknowledged. Browser profiles enable this automatically. Disabling clears its layout and probe batch.
func (*QUICSettings) InitialCryptoRecoveryLayout ΒΆ
func (q *QUICSettings) InitialCryptoRecoveryLayout(policy func(InitialCryptoLayoutInfo) [][]CryptoRange) *QUICSettings
InitialCryptoRecoveryLayout selects ordered lost ranges for each Initial packet's live budget. Offsets remain absolute across HelloRetryRequest; Length can include later Initial messages. A non-nil policy enables byte-range recovery. Nil restores sequential lost ranges while retaining the current recovery mode.
func (*QUICSettings) InitialCryptoResendOnPeerProbe ΒΆ
func (q *QUICSettings) InitialCryptoResendOnPeerProbe(enabled bool) *QUICSettings
InitialCryptoResendOnPeerProbe resends sent, unacknowledged Initial bytes on PING or CRYPTO input that delivers no new TLS bytes. Enabling also selects byte-range recovery. Browser profiles configure their own policy.
func (*QUICSettings) InitialDestinationConnectionIDLength ΒΆ
func (q *QUICSettings) InitialDestinationConnectionIDLength(length int) *QUICSettings
InitialDestinationConnectionIDLength sets the Initial destination ID length. Nonzero lengths must be 8 through 20; zero selects quic-go's default.
func (*QUICSettings) InitialDestinationConnectionIDLengthFactory ΒΆ
func (q *QUICSettings) InitialDestinationConnectionIDLengthFactory(factory func() (int, error)) *QUICSettings
InitialDestinationConnectionIDLengthFactory chooses a fresh 8..20 byte length per connection. Nil restores the fixed length. The factory may run concurrently.
func (*QUICSettings) InitialPTOMultiplier ΒΆ
func (q *QUICSettings) InitialPTOMultiplier(factor uint32) *QUICSettings
InitialPTOMultiplier controls probe timing before the first RTT measurement. Zero uses the native factor; supported explicit factors are 1..16.
func (*QUICSettings) InitialPacketNumber ΒΆ
func (q *QUICSettings) InitialPacketNumber(number uint64) *QUICSettings
InitialPacketNumber sets a fixed initial packet number and clears any factory.
func (*QUICSettings) InitialPacketNumberFactory ΒΆ
func (q *QUICSettings) InitialPacketNumberFactory(factory func() (uint64, error)) *QUICSettings
InitialPacketNumberFactory supplies a fresh initial number per connection. Nil restores the fixed number. The factory may run concurrently.
func (*QUICSettings) InitialPacketSize ΒΆ
func (q *QUICSettings) InitialPacketSize(size uint16) *QUICSettings
InitialPacketSize sets the initial packet size in bytes (at least 1200). Zero selects quic-go's default.
func (*QUICSettings) InitialPacketSizeFactory ΒΆ
func (q *QUICSettings) InitialPacketSizeFactory(factory func(net.Addr) (uint16, error)) *QUICSettings
InitialPacketSizeFactory selects the initial UDP payload size for the actual remote address. It must return promptly and be concurrency safe. Nil restores the fixed size. Results must fit the QUIC engine's supported packet sizes.
func (*QUICSettings) InitialPaddingMode ΒΆ
func (q *QUICSettings) InitialPaddingMode(mode quic.InitialPaddingMode) *QUICSettings
InitialPaddingMode selects encrypted PADDING or a zero-filled datagram tail after coalesced packets. Header-protection sample padding remains encrypted.
func (*QUICSettings) InitialPingFrames ΒΆ
func (q *QUICSettings) InitialPingFrames(min, max int) *QUICSettings
InitialPingFrames sets the inclusive random PING count in protected Initials. Both endpoints must be in 0..64. This does not affect 1-RTT ACK-only PINGs.
func (*QUICSettings) InitialProbeSkipPacketNumber ΒΆ
func (q *QUICSettings) InitialProbeSkipPacketNumber(enabled bool) *QUICSettings
InitialProbeSkipPacketNumber skips one Initial number when PTO fires to elicit an immediate ACK. This is independent of Application Data PacketNumberSkipping.
func (*QUICSettings) InitialRTT ΒΆ
func (q *QUICSettings) InitialRTT(estimate time.Duration) *QUICSettings
InitialRTT sets the local recovery estimate before the first measurement. Zero uses the native default. No transport parameter is advertised by it.
func (*QUICSettings) InitialStreamReceiveWindow ΒΆ
func (q *QUICSettings) InitialStreamReceiveWindow(size uint64) *QUICSettings
InitialStreamReceiveWindow sets the common initial stream receive window. It replaces any per-direction StreamReceiveWindows override.
func (*QUICSettings) KeepAlivePeriod ΒΆ
func (q *QUICSettings) KeepAlivePeriod(period time.Duration) *QUICSettings
KeepAlivePeriod sets the interval between keep-alive packets. Zero disables them.
func (*QUICSettings) LegacyAckFrequency ΒΆ
func (q *QUICSettings) LegacyAckFrequency(minimum time.Duration) *QUICSettings
LegacyAckFrequency enables the legacy single-byte ignore_order extension and advertises its minimum requested ACK delay. Zero disables it. The delay must be a whole number of microseconds no larger than MaxAckDelay. Local ACK policy remains in effect until a valid peer update arrives; this is receive support.
func (*QUICSettings) MaxAckDelay ΒΆ
func (q *QUICSettings) MaxAckDelay(delay time.Duration) *QUICSettings
MaxAckDelay sets the acknowledgment scheduling bound in whole milliseconds. Zero selects quic-go's default.
func (*QUICSettings) MaxCongestionWindowPackets ΒΆ
func (q *QUICSettings) MaxCongestionWindowPackets(packets int64) *QUICSettings
MaxCongestionWindowPackets caps the send window in accounting segments. Zero restores the engine default; -1 removes this packet-count ceiling.
func (*QUICSettings) MaxConnectionReceiveWindow ΒΆ
func (q *QUICSettings) MaxConnectionReceiveWindow(size uint64) *QUICSettings
MaxConnectionReceiveWindow sets the connection receive window limit.
func (*QUICSettings) MaxDatagramFrameSize ΒΆ
func (q *QUICSettings) MaxDatagramFrameSize(size uint64) *QUICSettings
MaxDatagramFrameSize sets the advertised QUIC datagram limit. Datagram support must also be enabled. Zero selects quic-go's default.
func (*QUICSettings) MaxIdleTimeout ΒΆ
func (q *QUICSettings) MaxIdleTimeout(timeout time.Duration) *QUICSettings
MaxIdleTimeout sets the maximum idle time after the handshake. Zero selects quic-go's default.
func (*QUICSettings) MaxIncomingStreams ΒΆ
func (q *QUICSettings) MaxIncomingStreams(limit int64) *QUICSettings
MaxIncomingStreams limits concurrent peer-initiated bidirectional streams. Zero selects quic-go's default; a negative value disallows them.
func (*QUICSettings) MaxIncomingUniStreams ΒΆ
func (q *QUICSettings) MaxIncomingUniStreams(limit int64) *QUICSettings
MaxIncomingUniStreams limits concurrent peer-initiated unidirectional streams. Zero selects quic-go's default; a negative value disallows them.
func (*QUICSettings) MaxStreamReceiveWindow ΒΆ
func (q *QUICSettings) MaxStreamReceiveWindow(size uint64) *QUICSettings
MaxStreamReceiveWindow sets the receive window limit for each stream.
func (*QUICSettings) MaxUDPPayloadSize ΒΆ
func (q *QUICSettings) MaxUDPPayloadSize(size uint64) *QUICSettings
MaxUDPPayloadSize sets the advertised UDP payload limit and actual receive size. It also enables advertising this parameter after OmitMaxUDPPayloadSize(true).
func (*QUICSettings) MinAckDelay ΒΆ
func (q *QUICSettings) MinAckDelay(delay time.Duration) *QUICSettings
MinAckDelay sets the floor for the RTT-scaled delay, within MaxAckDelay.
func (*QUICSettings) OmitInitialAckOnHandshake ΒΆ
func (q *QUICSettings) OmitInitialAckOnHandshake(omit bool) *QUICSettings
OmitInitialAckOnHandshake omits an ACK-only Initial when Handshake data is ready.
func (*QUICSettings) OmitLegacyResetStreamAt ΒΆ
func (q *QUICSettings) OmitLegacyResetStreamAt(omit bool) *QUICSettings
OmitLegacyResetStreamAt controls advertising the legacy reliable-reset parameter.
func (*QUICSettings) OmitMaxUDPPayloadSize ΒΆ
func (q *QUICSettings) OmitMaxUDPPayloadSize(omit bool) *QUICSettings
OmitMaxUDPPayloadSize omits the parameter and provisions the protocol default receive size when enabled. False advertises the current payload limit.
func (*QUICSettings) OnApplicationReady ΒΆ
func (q *QUICSettings) OnApplicationReady(callback func(*quic.Conn)) *QUICSettings
OnApplicationReady stages application data after verified TLS and peer parameters, before the next flight. It must not block or call CloseWithError; use OpenUniStream and TryWriteAll rather than blocking stream writes.
func (*QUICSettings) OnEarlyDataReady ΒΆ
func (q *QUICSettings) OnEarlyDataReady(callback func(*quic.Conn)) *QUICSettings
OnEarlyDataReady observes restored QUIC parameters and usable 0-RTT keys before the early connection is released. It does not authenticate the server or enable early data. The callback runs on the connection loop and must not block or reenter it; OpenUniStream and SendStream.TryWriteAll may stage bounded data. Nil removes this observer; HTTP/3's own initial-settings policy remains active.
func (*QUICSettings) OnEarlyDataRejected ΒΆ
func (q *QUICSettings) OnEarlyDataRejected(callback func(*quic.Conn)) *QUICSettings
OnEarlyDataRejected observes a TLS rejection of QUIC 0-RTT. It runs on the connection loop and must return promptly without reentering the connection. Nil removes the application observer; owned-cache rejection handling remains.
func (*QUICSettings) Pacing ΒΆ
func (q *QUICSettings) Pacing(algorithm PacingAlgorithm) *QUICSettings
Pacing selects the send scheduler independently of congestion control.
func (*QUICSettings) PacingBurstPackets ΒΆ
func (q *QUICSettings) PacingBurstPackets(packets uint32) *QUICSettings
PacingBurstPackets sets initial/idle burst credit in path-sized packets.
func (*QUICSettings) PacingGains ΒΆ
func (q *QUICSettings) PacingGains(slowStart, avoidance uint32) *QUICSettings
PacingGains sets slow-start and avoidance rate multipliers in thousandths.
func (*QUICSettings) PacingGranularity ΒΆ
func (q *QUICSettings) PacingGranularity(granularity time.Duration) *QUICSettings
PacingGranularity permits sends whose pacing delay is below this duration.
func (*QUICSettings) PacingLumpyBurst ΒΆ
func (q *QUICSettings) PacingLumpyBurst(packets, windowFraction uint32, minBandwidth uint64) *QUICSettings
PacingLumpyBurst limits scheduled bursts by packet count, window fraction (thousandths), and minimum estimated bandwidth in bytes per second.
func (*QUICSettings) PacketNumberLengthPolicy ΒΆ
func (q *QUICSettings) PacketNumberLengthPolicy(policy func(quic.PacketNumberLengthInfo) uint8) *QUICSettings
PacketNumberLengthPolicy chooses 1..4 encoded bytes per packet from live recovery state. Zero or invalid results retain native behavior; the transport increases results that cannot safely represent the unacknowledged range.
func (*QUICSettings) PacketNumberSkipping ΒΆ
func (q *QUICSettings) PacketNumberSkipping(enabled bool) *QUICSettings
PacketNumberSkipping controls random Application Data gaps. It also controls PTO gaps unless ApplicationProbeSkipPacketNumber explicitly overrides them. Peer ACK validation remains enabled.
func (*QUICSettings) PeerAckFrequencyPolicy ΒΆ
func (q *QUICSettings) PeerAckFrequencyPolicy(policy PeerAckFrequencyPolicy) *QUICSettings
PeerAckFrequencyPolicy selects outgoing legacy ACK_FREQUENCY requests after the peer advertises support. The callback receives live window, MTU and RTT state plus the last acknowledged request. Nil disables sending; local receive policy and its LegacyAckFrequency advertisement remain independent.
func (*QUICSettings) PeerPacketRecoveryPolicy ΒΆ
func (q *QUICSettings) PeerPacketRecoveryPolicy( policy func(quic.PeerPacketInfo) quic.PeerPacketRecovery, ) *QUICSettings
PeerPacketRecoveryPolicy selects responses to missing or retired peer keys. Authentication failures never invoke it. Nil restores native behavior.
func (*QUICSettings) PeerTransportParameters ΒΆ
func (q *QUICSettings) PeerTransportParameters(ids ...uint64) *QUICSettings
PeerTransportParameters selects unrecognized peer extension IDs to retain from each handshake. Values are available through Conn.PeerTransportParameter after verification and are not restored from session tickets. An empty list disables capture; the supplied IDs are copied.
func (*QUICSettings) PersistentCongestionThreshold ΒΆ
func (q *QUICSettings) PersistentCongestionThreshold(ptos uint32) *QUICSettings
PersistentCongestionThreshold sets the consecutive-loss duration in base PTOs. Zero preserves the engine's native behavior; a PTO expiry alone is not a loss.
func (*QUICSettings) PrioritizeFinishedStreams ΒΆ
func (q *QUICSettings) PrioritizeFinishedStreams(enabled bool) *QUICSettings
PrioritizeFinishedStreams sends queued bytes and FIN of write-closed streams alongside retransmissions before ordinary new data, retaining creation order within each class. It applies only with StreamSchedulingByCreation. Firefox enables this to match Neqo's DataSent scheduling; urgency scheduling is unchanged.
func (*QUICSettings) ProportionalRateReduction ΒΆ
func (q *QUICSettings) ProportionalRateReduction(enabled bool) *QUICSettings
ProportionalRateReduction enables RFC 6937's send allowance during recovery.
func (*QUICSettings) ReceiveBatchSize ΒΆ
func (q *QUICSettings) ReceiveBatchSize(size int) *QUICSettings
ReceiveBatchSize sets the maximum datagrams offered to one UDP batch read. Zero keeps the platform default; 1 through 255 select a capacity. Platforms and custom sockets without batch reads remain single-read. This does not combine outgoing packets or change the advertised UDP payload limit.
func (*QUICSettings) ReceiveWindowUpdateDivisor ΒΆ
func (q *QUICSettings) ReceiveWindowUpdateDivisor(divisor uint32) *QUICSettings
ReceiveWindowUpdateDivisor refreshes stream/connection credit after more than 1/divisor of its window is consumed. Zero retains native behavior; one is invalid.
func (*QUICSettings) RecoveryBurstPackets ΒΆ
func (q *QUICSettings) RecoveryBurstPackets(packets uint32) *QUICSettings
RecoveryBurstPackets permits an immediate bounded send after a new loss event.
func (*QUICSettings) RequireStreamCreditRelease ΒΆ
func (q *QUICSettings) RequireStreamCreditRelease(required bool) *QUICSettings
RequireStreamCreditRelease keeps completed peer streams counted until their credit is explicitly released. This is for applications managing incoming streams.
func (*QUICSettings) ResetAckPolicy ΒΆ
func (q *QUICSettings) ResetAckPolicy() *QUICSettings
ResetAckPolicy restores native receive ACK behavior, retaining MaxAckDelay.
func (*QUICSettings) ResetInitialPacketProtection ΒΆ
func (q *QUICSettings) ResetInitialPacketProtection() *QUICSettings
ResetInitialPacketProtection clears random Initial splits, PINGs and prefix sizing. Explicit InitialCryptoLayout and DisableClientHelloScrambling retain their independently configured values.
func (*QUICSettings) ResumeRTT ΒΆ
func (q *QUICSettings) ResumeRTT(precision time.Duration) *QUICSettings
ResumeRTT restores a measured RTT from the selected live TLS ticket, rounded down to the supplied precision. Zero disables restoration. Firefox uses whole milliseconds; this local recovery estimate does not advertise a parameter. The supported range is zero through one minute; Build rejects other values.
func (*QUICSettings) ResumeVersion ΒΆ
func (q *QUICSettings) ResumeVersion(enabled bool) *QUICSettings
ResumeVersion chooses the first QUIC version from an available session ticket previously stored by this client for the origin. Expired, evicted, unmarked and disabled-version tickets retain the configured first version. It does not reorder the caller's configuration. The Firefox profile enables this policy.
func (*QUICSettings) SeparatePacketNumberSpaces ΒΆ
func (q *QUICSettings) SeparatePacketNumberSpaces(enabled bool) *QUICSettings
SeparatePacketNumberSpaces starts Handshake and Application Data at zero, independently of Initial. 0-RTT and 1-RTT remain one space.
func (*QUICSettings) Set ΒΆ
func (q *QUICSettings) Set() *Builder
Set applies the accumulated QUIC settings and returns the main Builder.
func (*QUICSettings) SlowStart ΒΆ
func (q *QUICSettings) SlowStart(algorithm SlowStartAlgorithm) *QUICSettings
SlowStart selects classic acknowledged-byte growth or original HyStart. Native retains the engine's HyStart; Hybrid is not HyStart++.
func (*QUICSettings) SortConnectionIDFrames ΒΆ
func (q *QUICSettings) SortConnectionIDFrames(enabled bool) *QUICSettings
SortConnectionIDFrames sends queued NEW_CONNECTION_ID frames in ascending sequence order. Other control-frame types keep their native relative positions.
func (*QUICSettings) StreamDataRecovery ΒΆ
func (q *QUICSettings) StreamDataRecovery(enabled bool) *QUICSettings
StreamDataRecovery acknowledges STREAM byte ranges across all transmitted copies, including late originals and split retransmissions. Browser profiles enable it automatically; disabling retains the native frame recovery path.
func (*QUICSettings) StreamLossRetention ΒΆ
func (q *QUICSettings) StreamLossRetention(policy func(quic.StreamLossInfo) bool) *QUICSettings
StreamLossRetention selects the lifetime of lost STREAM packet ACK metadata. The callback receives transport measurements and must not block or reenter QUIC. Nil retains useful metadata up to the engine's packet tracking limit.
func (*QUICSettings) StreamReceiveWindows ΒΆ
func (q *QUICSettings) StreamReceiveWindows(bidiLocal, bidiRemote, uni uint64) *QUICSettings
StreamReceiveWindows sets initial bidirectional-local, bidirectional-remote and unidirectional receive windows. Zero explicitly advertises zero credit.
func (*QUICSettings) StreamSchedulingByCreation ΒΆ
func (q *QUICSettings) StreamSchedulingByCreation(enabled bool) *QUICSettings
StreamSchedulingByCreation drains writable streams in creation order instead of local urgency/incremental queues. Lost data retains precedence unless PrioritizeFinishedStreams groups finished writes in that same class. Blocked streams are skipped, and completed streams release bookkeeping. This mode takes precedence over StreamPriority. Firefox selects it for ordinary HTTP/3.
func (*QUICSettings) TLSClientFactory ΒΆ
func (q *QUICSettings) TLSClientFactory(factory tlsquic.NewClient) *QUICSettings
TLSClientFactory sets a custom QUIC TLS engine. Configure either this factory or ClientHelloSpec/ClientHelloFactory; using both returns an error.
func (*QUICSettings) TLSClientFactoryWrapper ΒΆ
func (q *QUICSettings) TLSClientFactoryWrapper( wrapper func(*quic.Conn, tlsquic.NewClient) tlsquic.NewClient, ) *QUICSettings
TLSClientFactoryWrapper decorates the native or browser TLS factory for each connection. The factory receives a private TLS config with destination and ALPN set. The wrapper must preserve session events and must not perform network I/O. HTTP/3 adds its per-ticket SETTINGS bookkeeping outside this wrapper. Nil removes the application wrapper without changing the selected TLS engine.
func (*QUICSettings) TokenStore ΒΆ
func (q *QUICSettings) TokenStore(store quic.TokenStore) *QUICSettings
TokenStore sets the shared store of address validation tokens. Nil disables it.
func (*QUICSettings) Tracer ΒΆ
func (q *QUICSettings) Tracer(tracer func(context.Context, bool, quic.ConnectionID) qlogwriter.Trace) *QUICSettings
Tracer supplies a trace recorder for each new QUIC connection.
func (*QUICSettings) TransportParameter ΒΆ
func (q *QUICSettings) TransportParameter(id uint64, value []byte) *QUICSettings
TransportParameter adds or replaces an extension parameter with wire-encoded bytes. The value is copied. Engine-owned parameters must use their own setters. Advertising a parameter does not implement an extension protocol.
func (*QUICSettings) TransportParameterOrder ΒΆ
func (q *QUICSettings) TransportParameterOrder(ids ...uint64) *QUICSettings
TransportParameterOrder sets preferred parameter order. Unlisted parameters follow in their original order. Use transportparams.Grease for native GREASE. The order is copied and also applies to layouts generated by a browser factory.
func (*QUICSettings) TransportParametersFactory ΒΆ
func (q *QUICSettings) TransportParametersFactory( factory func(quic.Version) (*transportparams.Layout, error), ) *QUICSettings
TransportParametersFactory supplies a layout per handshake attempt, replacing any previous factory and its edits. Later layout setters amend its result. The factory may run concurrently. Nil restores the static layout.
func (*QUICSettings) ValidatePeerTransportParameters ΒΆ
func (q *QUICSettings) ValidatePeerTransportParameters(validate func([]transportparams.Parameter) error) *QUICSettings
ValidatePeerTransportParameters checks captured peer extensions before they are accepted. The callback receives private copies, runs before authentication on the connection loop, and must not block or reenter QUIC. An error rejects the handshake with TRANSPORT_PARAMETER_ERROR. Nil clears this validation.
func (*QUICSettings) Versions ΒΆ
func (q *QUICSettings) Versions(versions ...quic.Version) *QUICSettings
Versions sets the allowed QUIC versions. The input slice is copied. An empty list selects the versions supported by quic-go.
type Request ΒΆ
type Request struct {
// contains filtered or unexported fields
}
Request represents an HTTP request with additional surf-specific functionality. It wraps the standard http.Request and provides enhanced features like middleware support, retry capabilities, remote address tracking, and structured error handling.
func (*Request) AddCookies ΒΆ
AddCookies adds one or more HTTP cookies to the request. Cookies are added to the request headers and will be sent with the HTTP request. Returns the request for method chaining.
func (*Request) AddHeaders ΒΆ
AddHeaders adds HTTP headers to the request, appending to any existing headers with the same name. Unlike SetHeaders, this method preserves existing headers and adds new values. Supports the same input formats as SetHeaders. Returns the request for method chaining.
func (*Request) Body ΒΆ
Body sets the request body from various data types. Supported types include: []byte, string, g.String, g.Bytes, map[string]string, g.Map, g.MapOrd, and structs with json/xml tags. The Content-Type header is automatically detected and set based on the data. Returns the request for method chaining.
func (*Request) Do ΒΆ
Do executes the HTTP request and returns a Response wrapped in a Result type. This is the main method that performs the actual HTTP request with full surf functionality: - Applies request middleware (authentication, headers, tracing, etc.) - Preserves request body for potential retries - Implements retry logic with configurable status codes and delays - Measures request timing for performance analysis - Handles request preparation errors and write errors
func (*Request) Fetch ΒΆ
Fetch selects a browser's ordinary fetch header preset, such as an API request. GET and HEAD default to document navigation; call Fetch to use fetch defaults for Accept, Fetch Metadata and Priority instead. Other methods already default to fetch, so a normal POST API request does not need this call.
The HTTP method and body are configured by Get/Post/etc. and Body/StreamingBody. The selected scenario survives redirects, including HTTP origins where browsers omit Fetch Metadata. Explicit header values and ordered maps take precedence.
client.Get(url).Fetch().Do()
func (*Request) GetRequest ΒΆ
func (req *Request) GetRequest() *http.Request
GetRequest returns the underlying standard http.Request. Provides access to the wrapped HTTP request for advanced use cases.
func (*Request) HTTP3PriorityUpdates ΒΆ
func (req *Request) HTTP3PriorityUpdates(handler func(*HTTP3PriorityUpdater)) *Request
HTTP3PriorityUpdates calls handler after HTTP/3 request HEADERS are sent on each attempt. Return promptly; retain the updater to change priority while the response is open. HTTP/1 and HTTP/2 do not invoke the handler.
func (*Request) Multipart ΒΆ
Multipart sets multipart form data for the request. The provided Multipart object contains form fields and files to be sent. Returns the request for method chaining. If m is nil, an error is set on the request.
func (*Request) Navigation ΒΆ
Navigation selects a browser's document-navigation header preset. Use it for a POST that represents form navigation rather than an API fetch: its Accept, Fetch Metadata, Priority and cache defaults can differ from ordinary POST. GET and HEAD already default to navigation and usually do not need this call.
Get/Post/etc. and Body/Multipart still configure the HTTP method and payload. The scenario survives redirects; metadata is emitted only where the browser normally sends it. Explicit header values and ordered maps take precedence.
client.Post(url).Navigation().Body("name=surf").Do()
func (*Request) SetHeaders ΒΆ
SetHeaders sets HTTP headers for the request, replacing any existing headers with the same name. Supports multiple input formats: - Two arguments: key, value (string or g.String) - Single argument: http.Header, Headers, map types, or g.Map types Maintains header order for fingerprinting purposes when using g.MapOrd. Returns the request for method chaining.
func (*Request) StreamingBody ΒΆ
StreamingBody sends body without reading it into memory first. An optional length declares its size; omitted or -1 means unknown, and zero means empty. Surf owns and closes body. Blocking readers must implement Close so it unblocks Read, as required by http.Request.Body. This body is sent once: status retries, 307/308 redirects and protocol fallback need a replay factory. Cancellation and transport failure close body to release a pending read.
func (*Request) StreamingBodyFactory ΒΆ
func (req *Request) StreamingBodyFactory(factory func() (io.ReadCloser, error), length ...int64) *Request
StreamingBodyFactory creates a fresh streaming body for the initial attempt, retries, redirects and protocol fallback. No body is buffered. The factory is called when sending, must return a new non-nil reader on each call, and must be concurrency safe. Length follows StreamingBody; a zero-length body does not call the factory. Surf owns every reader returned by the factory.
func (*Request) WithContext ΒΆ
WithContext associates a context with the request for cancellation and deadlines. The context can be used to cancel the request, set timeouts, or pass request-scoped values. Returns the request for method chaining. If ctx is nil, the request is unchanged.
type Response ΒΆ
type Response struct {
Headers Headers // Response headers with convenience methods
Cookies Cookies // Response cookies with enhanced functionality
UserAgent g.String // User agent that was used for the request
Proto g.String // HTTP protocol version (HTTP/1.1, HTTP/2, HTTP/3)
*Client // Embedded client provides access to all client functionality
URL *url.URL // Final URL after following redirects
Body *Body // Enhanced response body with compression support and caching
Time time.Duration // Total request duration including retries
ContentLength int64 // Content-Length header value (-1 if not specified)
StatusCode StatusCode // HTTP status code with convenience methods
Attempts int // Number of retry attempts made for this request
// contains filtered or unexported fields
}
Response represents an HTTP response with enhanced functionality and metadata. It wraps the standard http.Response and provides additional features like timing information, retry attempts tracking, enhanced cookie management, and convenient access methods.
func (Response) GetCookies ΒΆ
func (resp Response) GetCookies(rawURL g.String) []*http.Cookie
GetCookies returns all cookies from the response that would be sent to the specified URL. Filters cookies based on domain, path, and security attributes.
func (Response) GetResponse ΒΆ
func (resp Response) GetResponse() *http.Response
GetResponse returns the underlying standard http.Response. Provides access to the wrapped HTTP response for advanced use cases.
func (Response) Location ΒΆ
func (resp Response) Location() g.String
Location returns the HTTP Location header value, typically used in redirects. Contains the URL that the client should redirect to for 3xx status codes.
func (Response) Referer ΒΆ
func (resp Response) Referer() g.String
Referer returns the HTTP Referer header value from the original request. This indicates which page linked to the resource being requested.
func (Response) RemoteAddress ΒΆ
RemoteAddress returns the network address of the server that sent this response. Useful for logging, debugging, or connection analysis.
func (*Response) SetCookies ΒΆ
SetCookies stores cookies in the client's cookie jar for the specified URL. This allows the cookies to be automatically sent with future requests to matching URLs.
func (Response) TLSGrabber ΒΆ
TLSGrabber extracts TLS connection information from the response. Returns detailed TLS connection data including certificates, cipher suites, and protocol version if the response was received over a TLS connection. Returns nil for non-TLS connections.
type SessionCache ΒΆ
type SessionCache struct {
// contains filtered or unexported fields
}
SessionCache configures TLS ticket caching through the client builder. Settings apply to TCP and QUIC by default; TCP, QUIC and Both select the transports affected by subsequent settings. Set returns the parent builder. Session separately enables cookie persistence.
func (*SessionCache) Both ΒΆ
func (s *SessionCache) Both() *SessionCache
Both applies subsequent settings to TCP and QUIC caches.
func (*SessionCache) Brotli ΒΆ
func (s *SessionCache) Brotli(quality int) *SessionCache
Brotli selects ticket compression quality 0..11; -1 disables compression. Firefox uses quality 1. Compressed records use Go's public session format, so their exact charged size differs from Firefox's NSS representation.
func (*SessionCache) ByteCapacity ΒΆ
func (s *SessionCache) ByteCapacity(bytes int) *SessionCache
ByteCapacity bounds charged queued-record bytes, from zero to 1 GiB. Zero disables the byte bound. Firefox defaults to 8 MiB; other profiles leave it disabled. Keys are charged per ticket; object overhead and consumed identities are excluded. Custom caches control their own storage.
func (*SessionCache) Capacity ΒΆ
func (s *SessionCache) Capacity(keys int) *SessionCache
Capacity bounds server keys, including recently consumed-ticket records. The valid range is 1..1048576. The generic default is 64; the Chrome/Firefox policies use 1024. Custom caches control their own limits.
func (*SessionCache) ClearEarlyDataOnReject ΒΆ
func (s *SessionCache) ClearEarlyDataOnReject(enabled bool) *SessionCache
ClearEarlyDataOnReject disables early data on remaining QUIC tickets after rejection, while retaining ordinary TLS resumption. Enabled by the Chrome QUIC policy; disabled by the generic and Firefox policies.
func (*SessionCache) Clock ΒΆ
func (s *SessionCache) Clock(clock func() time.Time) *SessionCache
Clock overrides ticket validity time. By default the cache uses TLSConfig.Time. Nil selects time.Now. This does not change the TLS engine's clock.
func (*SessionCache) Custom ΒΆ
func (s *SessionCache) Custom(cache tls.ClientSessionCache) *SessionCache
Custom supplies an application cache for the selected transports. Its policy takes precedence over browser defaults and queue settings. Nil disables the selected caches. Native and browser TCP use a separate "tcp:" key namespace.
func (*SessionCache) DiscardOnExpiry ΒΆ
func (s *SessionCache) DiscardOnExpiry(enabled bool) *SessionCache
DiscardOnExpiry removes the entire key when its next ticket expires. Otherwise individual expiry handling follows SkipExpired. The Chrome QUIC policy enables whole-entry expiry; the generic and Firefox policies do not.
func (*SessionCache) EvictionPolicy ΒΆ
func (s *SessionCache) EvictionPolicy(policy SessionCacheEviction) *SessionCache
EvictionPolicy selects byte-pressure eviction. Firefox removes individual tickets nearest expiry; other profiles default to least recently used keys.
func (*SessionCache) Group ΒΆ
func (s *SessionCache) Group(group func(*tls.ClientSessionState) string) *SessionCache
Group invalidates older tickets when the returned compatibility group changes. The callback runs outside cache locks and must be concurrency safe; it must not modify the supplied session. Nil disables compatibility grouping.
func (*SessionCache) Order ΒΆ
func (s *SessionCache) Order(order SessionTicketOrder) *SessionCache
Order selects the next ticket. Chrome and the generic cache select newest first; Firefox selects the nearest expiry, with new equal-expiry tickets first.
func (*SessionCache) QUIC ΒΆ
func (s *SessionCache) QUIC() *SessionCache
QUIC selects the HTTP/3 TLS cache for subsequent settings.
func (*SessionCache) ReuseTLS12 ΒΆ
func (s *SessionCache) ReuseTLS12(enabled bool) *SessionCache
ReuseTLS12 keeps legacy tickets reusable. TLS 1.3 tickets are consumed once. Enabled by the Chrome TCP policy; disabled by the other current policies.
func (*SessionCache) Set ΒΆ
func (s *SessionCache) Set() *Builder
Set applies the accumulated policy and returns the client builder. Invalid capacities or ordering are returned by Builder.Build. Caching does not enable cookie persistence or override TLSConfig.SessionTicketsDisabled.
func (*SessionCache) Shared ΒΆ
func (s *SessionCache) Shared(enabled bool) *SessionCache
Shared selects one owned TCP/QUIC cache and byte budget. Firefox enables it by default; Chrome keeps independent queues. Key namespaces remain separate. Explicit TCP/QUIC policy settings default to independent caches. Shared(true) with such settings is rejected: use Both for a common policy or Shared(false). A profile with distinct TCP/QUIC defaults cannot enable sharing. Application-supplied caches retain their own ownership and policy.
func (*SessionCache) SkipExpired ΒΆ
func (s *SessionCache) SkipExpired(enabled bool) *SessionCache
SkipExpired continues lookup after removing an expired ticket. False returns a miss and leaves the next ticket for a later connection. DiscardOnExpiry takes precedence when enabled.
func (*SessionCache) TCP ΒΆ
func (s *SessionCache) TCP() *SessionCache
TCP selects the HTTP/1 and HTTP/2 TLS cache for subsequent settings.
func (*SessionCache) TLS12TicketPolicy ΒΆ
func (s *SessionCache) TLS12TicketPolicy(policy func(TLS12TicketMetadata) TLS12TicketValidity) *SessionCache
TLS12TicketPolicy sets legacy ticket policy using authenticated engine facts. It runs once per insertion, outside cache locks, and must be concurrency safe. Missing metadata is a miss; nil restores generic certificate-bounded caching. TLS 1.3 and application-supplied caches retain their own policy.
func (*SessionCache) TicketsPerKey ΒΆ
func (s *SessionCache) TicketsPerKey(tickets int) *SessionCache
TicketsPerKey bounds available tickets for each TLS cache key, in 1..1024. The generic default is one; Chrome keeps two and Firefox keeps ten.
type SessionCacheEviction ΒΆ
type SessionCacheEviction = tlscache.EvictionPolicy
SessionCacheEviction selects which state is removed under byte pressure.
type SessionTicketOrder ΒΆ
SessionTicketOrder selects the next available ticket for a connection.
type SlowStartAlgorithm ΒΆ
type SlowStartAlgorithm = quic.SlowStartAlgorithm
type StatusCode ΒΆ
type StatusCode int
StatusCode represents an HTTP status code with convenient classification methods. Extends the basic integer status code with methods to easily identify the response category.
func (StatusCode) IsClientError ΒΆ
func (s StatusCode) IsClientError() bool
IsClientError returns true if the status code indicates a client error [400, 500].
func (StatusCode) IsInformational ΒΆ
func (s StatusCode) IsInformational() bool
IsInformational returns true if the status code is in the informational range [100, 200].
func (StatusCode) IsRedirection ΒΆ
func (s StatusCode) IsRedirection() bool
IsRedirection returns true if the status code indicates a redirection [300, 400].
func (StatusCode) IsServerError ΒΆ
func (s StatusCode) IsServerError() bool
IsServerError returns true if the status code indicates a server error [500, β].
func (StatusCode) IsSuccess ΒΆ
func (s StatusCode) IsSuccess() bool
IsSuccess returns true if the status code indicates a successful response [200, 300].
func (StatusCode) Text ΒΆ
func (s StatusCode) Text() string
Text returns the textual representation of the status code.
type StreamReader ΒΆ
StreamReader wraps bufio.Reader with Close support.
func (*StreamReader) Close ΒΆ
func (s *StreamReader) Close() error
Close closes the underlying body.
type TCPKeepAliveInfo ΒΆ
type TCPKeepAliveInfo = profiles.TCPKeepAliveInfo
TCPKeepAliveInfo describes a Surf-owned TCP socket and negotiated protocol.
type TCPKeepAliveOptions ΒΆ
type TCPKeepAliveOptions = profiles.TCPKeepAliveOptions
TCPKeepAliveOptions selects initial keepalive and an optional timed transition.
type TLS12TicketMetadata ΒΆ
type TLS12TicketMetadata = tlscache.TLS12TicketMetadata
TLS12TicketMetadata contains authenticated issuance times and session lineage.
type TLS12TicketValidity ΒΆ
type TLS12TicketValidity = tlscache.TLS12TicketValidity
TLS12TicketValidity controls legacy ticket retention and wire-offer bounds.
type TLSData ΒΆ
type TLSData struct {
CommonName []string // List of common names associated with the certificate.
DNSNames []string // List of DNS names associated with the certificate.
Emails []string // List of email addresses associated with the certificate.
IssuerCommonName []string // List of common names of the certificate issuer.
IssuerOrg []string // List of organizations of the certificate issuer.
Organization []string // List of organizations associated with the certificate.
ExtensionServerName string // Server name extension of the TLS certificate.
FingerprintSHA256 string // SHA-256 fingerprint of the certificate.
FingerprintSHA256OpenSSL string // SHA-256 fingerprint compatible with OpenSSL.
TLSVersion string // TLS version used.
}
TLSData represents information about a TLS certificate.
type TransportAdapter ΒΆ
type TransportAdapter struct {
// contains filtered or unexported fields
}
TransportAdapter adapts surf.Client to net/http.RoundTripper It uses the full surf pipeline including middleware
func (*TransportAdapter) CloseIdleConnections ΒΆ
func (s *TransportAdapter) CloseIdleConnections()
Source Files
ΒΆ
- body.go
- builder.go
- client.go
- client_hints.go
- client_hints_alps.go
- client_hints_alps_tcp.go
- client_hints_cache.go
- client_hints_clear_site_data.go
- client_hints_config.go
- client_hints_parser.go
- client_hints_transport.go
- cookies.go
- debug.go
- defaults.go
- dns_over_tls.go
- errors.go
- headers.go
- http1_settings.go
- http2_required.go
- http2_settings.go
- http3_qpack.go
- http3_settings.go
- impersonate.go
- ja.go
- ja_network_change.go
- ja_preconnect.go
- ja_proxy.go
- ja_roundtripper.go
- ja_session_cache.go
- middleware.go
- middleware_client.go
- middleware_request.go
- middleware_response.go
- multipart.go
- network_change.go
- network_settings.go
- pools.go
- profile_adapter.go
- profile_quic_adapter.go
- profile_wire_adapter.go
- quic_settings.go
- request.go
- request_body_stream.go
- request_profile_headers.go
- response.go
- session_cache.go
- status.go
- std_adapter.go
- tcp_keepalive.go
- tls.go
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
examples
|
|
|
async/async_get
command
|
|
|
async/async_get_context
command
|
|
|
async/async_get_std
command
|
|
|
auth/basic_auth
command
|
|
|
auth/bearer_basic
command
|
|
|
cache/body_cache
command
|
|
|
cache/cache
command
|
|
|
compression
command
|
|
|
context
command
|
|
|
cookies
command
|
|
|
custom/custom_client
command
|
|
|
custom/custom_tls_certificate
command
|
|
|
custom/custom_transport
command
|
|
|
debug
command
|
|
|
dns/custom_dns
command
|
|
|
dns/dns_over_tls
command
|
|
|
download/download_file
command
|
|
|
download/download_file_async
command
|
|
|
download/download_file_async_std
command
|
|
|
file_upload
command
|
|
|
headers/client_hints
command
|
|
|
headers/content_type
command
|
|
|
headers/headers
command
|
|
|
headers/headers_ordered
command
|
|
|
headers/presets
command
|
|
|
http/get
command
|
|
|
http/h2c
command
|
|
|
http/head
command
|
|
|
http/http1
command
|
|
|
http/http2
command
|
|
|
http/http2_custom
command
|
|
|
http/http3
command
|
|
|
http/http3_connection_racing
command
|
|
|
http/http3_custom
command
|
|
|
http/http3_discovery
command
|
|
|
http/http3_early_racing
command
|
|
|
http/http3_rtt
command
|
|
|
http/write_policies
command
|
|
|
impersonate/impersonate
command
|
|
|
impersonate/impersonate_async
command
|
|
|
impersonate/impersonate_custom
command
|
|
|
impersonate/impersonate_session
command
|
|
|
ja_hello/chrome
command
|
|
|
ja_hello/ja_hello_spec
command
|
|
|
keep_alive
command
|
|
|
limiter
command
|
|
|
md5
command
|
|
|
middleware
command
|
|
|
multipart
command
|
|
|
network
command
|
|
|
no_redirect
command
|
|
|
post
command
|
|
|
post/post_stream
command
|
|
|
proxy/rotating
command
|
|
|
proxy/simple
command
|
|
|
raw
command
|
|
|
redirect
command
|
|
|
remote_address
command
|
|
|
retry
command
|
|
|
session
command
|
|
|
session/ticket_cache
command
|
|
|
split_request
command
|
|
|
sse
command
|
|
|
std/std
command
|
|
|
std/std_cookies
command
|
|
|
stream
command
|
|
|
timeout
command
|
|
|
tls
command
|
|
|
tls/ech
command
|
|
|
unix_socket
command
|
|
|
user_agent
command
|
|
|
utf8
command
|
|
|
internal
|
|
|
alps
Package alps decodes authenticated application-layer protocol settings.
|
Package alps decodes authenticated application-layer protocol settings. |
|
clientdialer
Package clientdialer identifies Surf's default TCP dial functions.
|
Package clientdialer identifies Surf's default TCP dial functions. |
|
connrace
Package connrace coordinates connection preparation without sending requests.
|
Package connrace coordinates connection preparation without sending requests. |
|
echretry
Package echretry carries authenticated ECH retry metadata for one connection attempt.
|
Package echretry carries authenticated ECH retry metadata for one connection attempt. |
|
http3
Package h3transport owns HTTP/3 execution and authenticated alternative routing.
|
Package h3transport owns HTTP/3 execution and authenticated alternative routing. |
|
netchange
Package netchange delivers native network notifications to built clients.
|
Package netchange delivers native network notifications to built clients. |
|
origin
Package origin supplies shared HTTP origin classification for browser policies.
|
Package origin supplies shared HTTP origin classification for browser policies. |
|
quic
Package quictransport owns UDP sockets and QUIC connection establishment.
|
Package quictransport owns UDP sockets and QUIC connection establishment. |
|
quictls
Package quictls adapts the uTLS QUIC API to the transport's event interface.
|
Package quictls adapts the uTLS QUIC API to the transport's event interface. |
|
retryafter
Package retryafter parses values of the HTTP Retry-After header as defined by RFC 7231 Β§7.1.3.
|
Package retryafter parses values of the HTTP Retry-After header as defined by RFC 7231 Β§7.1.3. |
|
specclone
Package specclone provides deep cloning functionality for uTLS ClientHelloSpec structures.
|
Package specclone provides deep cloning functionality for uTLS ClientHelloSpec structures. |
|
tlsstate
Package tlsstate adapts public TLS state across the standard and uTLS APIs.
|
Package tlsstate adapts public TLS state across the standard and uTLS APIs. |
|
pkg
|
|
|
quicconn
Package quicconn provides a net.PacketConn adapter for feeding QUIC stacks (such as quic-go) with datagrams originating from a generic net.Conn.
|
Package quicconn provides a net.PacketConn adapter for feeding QUIC stacks (such as quic-go) with datagrams originating from a generic net.Conn. |
|
tlscache
Package tlscache provides bounded TLS ticket queues for browser profiles and applications.
|
Package tlscache provides bounded TLS ticket queues for browser profiles and applications. |
|
Package profiles defines the shared variant contract used by browser profile packages (profiles/chrome, profiles/firefox, ...) and consumed by the top-level surf package.
|
Package profiles defines the shared variant contract used by browser profile packages (profiles/chrome, profiles/firefox, ...) and consumed by the top-level surf package. |
|
internal/ech
Package ech contains wire helpers shared by browser-owned ECH policies.
|
Package ech contains wire helpers shared by browser-owned ECH policies. |
|
tests
|
|
|
internal/alpspeer
Package alpspeer supplies an authenticated test-only QUIC TLS transcript peer.
|
Package alpspeer supplies an authenticated test-only QUIC TLS transcript peer. |
|
internal/echcapture
Package echcapture reads captured TLS messages without retaining live tickets in public reference files.
|
Package echcapture reads captured TLS messages without retaining live tickets in public reference files. |
|
internal/wiretest
Package wiretest normalizes serialized browser handshakes for golden tests.
|
Package wiretest normalizes serialized browser handshakes for golden tests. |
|
tools/browserpeer
command
|
|
|
tools/echresumption
command
echresumption verifies private captured pairs and writes sanitized references.
|
echresumption verifies private captured pairs and writes sanitized references. |
|
tools/sessioncache
command
The sessioncache command serves a trusted-profile cache-pressure fixture.
|
The sessioncache command serves a trusted-profile cache-pressure fixture. |
|
tools/wirecapture
command
|