http2

package
v1.0.50 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package http2 exposes HTTP/2 transports and frame APIs backed by the single HTTP/2 engine in codeberg.org/enetx/http. No second protocol engine is compiled. The public adapter is maintained for Surf's wire configuration, connection APIs and h2c Upgrade support.

Index

Constants

View Source
const (
	HPACKDefault              = native.HPACKDefault
	HPACKWithoutIndexing      = native.HPACKWithoutIndexing
	HPACKNeverIndex           = native.HPACKNeverIndex
	HPACKIncrementalIndexing  = native.HPACKIncrementalIndexing
	HPACKHuffmanDefault       = native.HPACKHuffmanDefault
	HPACKHuffmanAlways        = native.HPACKHuffmanAlways
	HPACKHuffmanNever         = native.HPACKHuffmanNever
	HPACKNameReferenceDefault = native.HPACKNameReferenceDefault
	HPACKNameReferenceLast    = native.HPACKNameReferenceLast
	HPACKNameReferenceFirst   = native.HPACKNameReferenceFirst
)
View Source
const ClientPreface = native.ClientPreface
View Source
const ErrCodeCancel = native.ErrCodeCancel
View Source
const ErrCodeCompression = native.ErrCodeCompression
View Source
const ErrCodeConnect = native.ErrCodeConnect
View Source
const ErrCodeEnhanceYourCalm = native.ErrCodeEnhanceYourCalm
View Source
const ErrCodeFlowControl = native.ErrCodeFlowControl
View Source
const ErrCodeFrameSize = native.ErrCodeFrameSize
View Source
const ErrCodeHTTP11Required = native.ErrCodeHTTP11Required
View Source
const ErrCodeInadequateSecurity = native.ErrCodeInadequateSecurity
View Source
const ErrCodeInternal = native.ErrCodeInternal
View Source
const ErrCodeNo = native.ErrCodeNo
View Source
const ErrCodeProtocol = native.ErrCodeProtocol
View Source
const ErrCodeRefusedStream = native.ErrCodeRefusedStream
View Source
const ErrCodeSettingsTimeout = native.ErrCodeSettingsTimeout
View Source
const ErrCodeStreamClosed = native.ErrCodeStreamClosed
View Source
const FlagContinuationEndHeaders = native.FlagContinuationEndHeaders
View Source
const FlagDataEndStream = native.FlagDataEndStream
View Source
const FlagDataPadded = native.FlagDataPadded
View Source
const FlagHeadersEndHeaders = native.FlagHeadersEndHeaders
View Source
const FlagHeadersEndStream = native.FlagHeadersEndStream
View Source
const FlagHeadersPadded = native.FlagHeadersPadded
View Source
const FlagHeadersPriority = native.FlagHeadersPriority
View Source
const FlagPingAck = native.FlagPingAck
View Source
const FlagPushPromiseEndHeaders = native.FlagPushPromiseEndHeaders
View Source
const FlagPushPromisePadded = native.FlagPushPromisePadded
View Source
const FlagSettingsAck = native.FlagSettingsAck
View Source
const FrameContinuation = native.FrameContinuation
View Source
const FrameData = native.FrameData
View Source
const FrameGoAway = native.FrameGoAway
View Source
const FrameHeaders = native.FrameHeaders
View Source
const FramePing = native.FramePing
View Source
const FramePriority = native.FramePriority
View Source
const FramePriorityUpdate = native.FramePriorityUpdate
View Source
const FramePushPromise = native.FramePushPromise
View Source
const FrameRSTStream = native.FrameRSTStream
View Source
const FrameSettings = native.FrameSettings
View Source
const FrameWindowUpdate = native.FrameWindowUpdate
View Source
const NextProtoTLS = native.NextProtoTLS
View Source
const SettingEnableConnectProtocol = native.SettingEnableConnectProtocol
View Source
const SettingEnablePush = native.SettingEnablePush
View Source
const SettingHeaderTableSize = native.SettingHeaderTableSize
View Source
const SettingInitialWindowSize = native.SettingInitialWindowSize
View Source
const SettingMaxConcurrentStreams = native.SettingMaxConcurrentStreams
View Source
const SettingMaxFrameSize = native.SettingMaxFrameSize
View Source
const SettingMaxHeaderListSize = native.SettingMaxHeaderListSize
View Source
const SettingNoRFC7540Priorities = native.SettingNoRFC7540Priorities
View Source
const TrailerPrefix = "Trailer:"

TrailerPrefix is a magic prefix for ResponseWriter.Header map keys that, if present, signals that the map entry is actually for the response trailers, and not the response headers. The prefix is stripped after the ServeHTTP call finishes and the values are sent in the trailers.

This mechanism is intended only for trailers that are not known prior to the headers being written. If the set of trailers is fixed or known before the header is written, the normal Go trailers mechanism is preferred:

https://golang.org/pkg/net/http/#ResponseWriter
https://golang.org/pkg/net/http/#example_ResponseWriter_trailers

Variables

View Source
var (
	ErrRecursivePush    = errors.New("http2: recursive push not allowed")
	ErrPushLimitReached = errors.New("http2: push would exceed peer's SETTINGS_MAX_CONCURRENT_STREAMS")
)

Push errors.

View Source
var ErrNoCachedConn error = noCachedConnError{}

Functions

func ConfigureServer

func ConfigureServer(s *http.Server, conf *Server) error

ConfigureServer adds HTTP/2 support to a net/http Server.

The configuration conf may be nil.

ConfigureServer must be called before s begins serving.

func ConfigureTransport

func ConfigureTransport(t1 *http.Transport) error

ConfigureTransport configures a net/http HTTP/1 Transport to use HTTP/2. It returns an error if t1 has already been HTTP/2-enabled.

Use ConfigureTransports instead to configure the HTTP/2 Transport.

func SetVerboseLogs

func SetVerboseLogs(enabled bool)

SetVerboseLogs configures native HTTP/2 diagnostics before starting any transports or servers. GODEBUG=http2debug=1 is the equivalent startup option.

Types

type ClientConn

type ClientConn struct {
	// contains filtered or unexported fields
}

ClientConn is the state of a single HTTP/2 client connection to an HTTP/2 server.

func (*ClientConn) CanTakeNewRequest

func (cc *ClientConn) CanTakeNewRequest() bool

CanTakeNewRequest reports whether the connection can take a new request, meaning it has not been closed or received or sent a GOAWAY.

If the caller is going to immediately make a new request on this connection, use ReserveNewRequest instead.

func (*ClientConn) Close

func (cc *ClientConn) Close() error

Close closes the client connection immediately.

In-flight requests are interrupted. For a graceful shutdown, use Shutdown instead.

func (*ClientConn) Ping

func (cc *ClientConn) Ping(ctx context.Context) error

Ping sends a PING frame to the server and waits for the ack.

func (*ClientConn) ReserveNewRequest

func (cc *ClientConn) ReserveNewRequest() bool

ReserveNewRequest is like CanTakeNewRequest but also reserves a concurrent stream in cc. The reservation is decremented on the next call to RoundTrip.

func (*ClientConn) RoundTrip

func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error)

func (*ClientConn) SetDoNotReuse

func (cc *ClientConn) SetDoNotReuse()

SetDoNotReuse marks cc as not reusable for future HTTP requests.

func (*ClientConn) Shutdown

func (cc *ClientConn) Shutdown(ctx context.Context) error

Shutdown gracefully closes the client connection, waiting for running streams to complete.

func (*ClientConn) State

func (cc *ClientConn) State() ClientConnState

State returns a snapshot of cc's state.

type ClientConnPool

type ClientConnPool interface {
	// GetClientConn returns a specific HTTP/2 connection (usually
	// a TLS-TCP connection) to an HTTP/2 server. On success, the
	// returned ClientConn accounts for the upcoming RoundTrip
	// call, so the caller should not omit it. If the caller needs
	// to, ClientConn.RoundTrip can be called with a bogus
	// new(http.Request) to release the stream reservation.
	GetClientConn(req *http.Request, addr string) (*ClientConn, error)
	MarkDead(*ClientConn)
}

ClientConnPool manages a pool of HTTP/2 client connections.

type ClientConnState

type ClientConnState struct {
	// Closed is whether the connection is closed.
	Closed bool

	// Closing is whether the connection is in the process of
	// closing. It may be closing due to shutdown, being a
	// single-use connection, being marked as DoNotReuse, or
	// having received a GOAWAY frame.
	Closing bool

	// StreamsActive is how many streams are active.
	StreamsActive int

	// StreamsReserved is how many streams have been reserved via
	// ClientConn.ReserveNewRequest.
	StreamsReserved int

	// StreamsPending is how many requests have been sent in excess
	// of the peer's advertised MaxConcurrentStreams setting and
	// are waiting for other streams to complete.
	StreamsPending int

	// MaxConcurrentStreams is how many concurrent streams the
	// peer advertised as acceptable. Zero means no SETTINGS
	// frame has been received yet.
	MaxConcurrentStreams uint32

	// LastIdle, if non-zero, is when the connection last
	// transitioned to idle state.
	LastIdle time.Time
}

ClientConnState describes the state of a ClientConn.

type ConnectionCloseInfo

type ConnectionCloseInfo = native.ConnectionCloseInfo

ConnectionCloseInfo describes a terminal close before the socket is closed.

type ConnectionCloseOptions

type ConnectionCloseOptions = native.ConnectionCloseOptions

ConnectionCloseOptions selects the optional final GOAWAY frame.

type ConnectionError

type ConnectionError = native.ConnectionError

type ConnectionErrorInfo

type ConnectionErrorInfo = native.ConnectionErrorInfo

type ContinuationFrame

type ContinuationFrame = native.ContinuationFrame

type DataFrame

type DataFrame = native.DataFrame

type ErrCode

type ErrCode = native.ErrCode

type Flags

type Flags = native.Flags

type Frame

type Frame = native.Frame

type FrameHeader

type FrameHeader = native.FrameHeader

func ReadFrameHeader

func ReadFrameHeader(r io.Reader) (FrameHeader, error)

type FrameType

type FrameType = native.FrameType

type Framer

type Framer = native.Framer

func NewFramer

func NewFramer(w io.Writer, r io.Reader) *Framer

type GoAwayError

type GoAwayError = native.GoAwayError

GoAwayError is returned by the Transport when the server closes the TCP connection after sending a GOAWAY frame.

type GoAwayFrame

type GoAwayFrame = native.GoAwayFrame

type HPACKConfig

type HPACKConfig = native.HPACKConfig

type HPACKHuffmanMode

type HPACKHuffmanMode = native.HPACKHuffmanMode

type HPACKNameReferencePolicy

type HPACKNameReferencePolicy = native.HPACKNameReferencePolicy

type HPACKRepresentation

type HPACKRepresentation = native.HPACKRepresentation

type HeadersFrame

type HeadersFrame = native.HeadersFrame

type HeadersFrameParam

type HeadersFrameParam = native.HeadersFrameParam

type MetaHeadersFrame

type MetaHeadersFrame = native.MetaHeadersFrame

type PingFrame

type PingFrame = native.PingFrame

type PriorityFrame

type PriorityFrame = native.PriorityFrame

type PriorityParam

type PriorityParam = native.PriorityParam

type PriorityRequest

type PriorityRequest = native.PriorityRequest

type PriorityUpdateFrame

type PriorityUpdateFrame = native.PriorityUpdateFrame

type PushPromiseFrame

type PushPromiseFrame = native.PushPromiseFrame

type PushPromiseParam

type PushPromiseParam = native.PushPromiseParam

type RSTStreamFrame

type RSTStreamFrame = native.RSTStreamFrame

type ReceiveWindowUpdateInfo

type ReceiveWindowUpdateInfo = native.ReceiveWindowUpdateInfo

type RequestBodyInfo

type RequestBodyInfo = native.RequestBodyInfo

RequestBodyInfo describes an HTTP/2 upload without reading its body.

type RequestBodyOptions

type RequestBodyOptions = native.RequestBodyOptions

RequestBodyOptions controls upload reads and DATA framing.

type RequestHeaderField

type RequestHeaderField = native.RequestHeaderField

RequestHeaderField is an effective, ordered HTTP/2 request field.

type RoundTripOpt

type RoundTripOpt struct {

	// Deprecated: OnlyCachedConn is ignored unless a custom ConnPool is set.
	OnlyCachedConn bool
}

RoundTripOpt are options for the Transport.RoundTripOpt method.

type ServeConnOpts

type ServeConnOpts struct {
	// Context is the base context to use.
	// If nil, context.Background is used.
	Context context.Context

	// BaseConfig optionally sets the base configuration
	// for values. If nil, defaults are used.
	BaseConfig *http.Server

	// Handler specifies which handler to use for processing
	// requests. If nil, BaseConfig.Handler is used. If BaseConfig
	// or BaseConfig.Handler is nil, http.DefaultServeMux is used.
	Handler http.Handler

	// UpgradeRequest is an initial request received on a connection
	// undergoing an h2c upgrade. The request body must have been
	// completely read from the connection before calling ServeConn,
	// and the 101 Switching Protocols response written.
	UpgradeRequest *http.Request

	// Settings is the decoded contents of the HTTP2-Settings header
	// in an h2c upgrade request.
	Settings []byte

	// SawClientPreface is set if the HTTP/2 connection preface
	// has already been read from the connection.
	SawClientPreface bool
}

ServeConnOpts are options for the Server.ServeConn method.

type Server

type Server struct {
	// MaxHandlers limits the number of http.Handler ServeHTTP goroutines
	// which may run at a time over all connections.
	// Negative or zero no limit.
	// TODO: implement
	//
	// Deprecated: This field has never had any effect.
	MaxHandlers int

	// MaxConcurrentStreams optionally specifies the number of
	// concurrent streams that each client may have open at a
	// time. This is unrelated to the number of http.Handler goroutines
	// which may be active globally, which is MaxHandlers.
	// If zero, MaxConcurrentStreams defaults to at least 100, per
	// the HTTP/2 spec's recommendations.
	MaxConcurrentStreams uint32

	// MaxDecoderHeaderTableSize optionally specifies the http2
	// SETTINGS_HEADER_TABLE_SIZE to send in the initial settings frame. It
	// informs the remote endpoint of the maximum size of the header compression
	// table used to decode header blocks, in octets. If zero, the default value
	// of 4096 is used.
	MaxDecoderHeaderTableSize uint32

	// MaxEncoderHeaderTableSize optionally specifies an upper limit for the
	// header compression table used for encoding request headers. Received
	// SETTINGS_HEADER_TABLE_SIZE settings are capped at this limit. If zero,
	// the default value of 4096 is used.
	MaxEncoderHeaderTableSize uint32

	// MaxReadFrameSize optionally specifies the largest frame
	// this server is willing to read. A valid value is between
	// 16k and 16M, inclusive. If zero or otherwise invalid, a
	// default value is used.
	MaxReadFrameSize uint32

	// PermitProhibitedCipherSuites, if true, permits the use of
	// cipher suites prohibited by the HTTP/2 spec.
	PermitProhibitedCipherSuites bool

	// IdleTimeout specifies how long until idle clients should be
	// closed with a GOAWAY frame. PING frames are not considered
	// activity for the purposes of IdleTimeout.
	// If zero or negative, there is no timeout.
	IdleTimeout time.Duration

	// ReadIdleTimeout is the timeout after which a health check using a ping
	// frame will be carried out if no frame is received on the connection.
	// If zero, no health check is performed.
	ReadIdleTimeout time.Duration

	// PingTimeout is the timeout after which the connection will be closed
	// if a response to a ping is not received.
	// If zero, a default of 15 seconds is used.
	PingTimeout time.Duration

	// WriteByteTimeout is the timeout after which a connection will be
	// closed if no data can be written to it. The timeout begins when data is
	// available to write, and is extended whenever any bytes are written.
	// If zero or negative, there is no timeout.
	WriteByteTimeout time.Duration

	// MaxUploadBufferPerConnection is the size of the initial flow
	// control window for each connections. The HTTP/2 spec does not
	// allow this to be smaller than 65535 or larger than 2^32-1.
	// If the value is outside this range, a default value will be
	// used instead.
	MaxUploadBufferPerConnection int32

	// MaxUploadBufferPerStream is the size of the initial flow control
	// window for each stream. The HTTP/2 spec does not allow this to
	// be larger than 2^32-1. If the value is zero or larger than the
	// maximum, a default value will be used instead.
	MaxUploadBufferPerStream int32

	// CountError, if non-nil, is called on HTTP/2 server errors.
	// It's intended to increment a metric for monitoring, such
	// as an expvar or Prometheus metric.
	// The errType consists of only ASCII word characters.
	CountError func(errType string)
	// contains filtered or unexported fields
}

Server is an HTTP/2 server.

func (*Server) ServeConn

func (s *Server) ServeConn(c net.Conn, opts *ServeConnOpts)

ServeConn serves HTTP/2 requests on the provided connection and blocks until the connection is no longer readable.

ServeConn starts speaking HTTP/2 assuming that c has not had any reads or writes. It writes its initial settings frame and expects to be able to read the preface and settings frame from the client. If c has a ConnectionState method like a *tls.Conn, the ConnectionState is used to verify the TLS ciphersuite and to set the Request.TLS field in Handlers.

ServeConn does not support h2c by itself. Any h2c support must be implemented in terms of providing a suitably-behaving net.Conn.

The opts parameter is optional. If nil, default values are used.

type Setting

type Setting = native.Setting

type SettingID

type SettingID = native.SettingID

type SettingsFrame

type SettingsFrame = native.SettingsFrame

type StreamError

type StreamError = native.StreamError

type Transport

type Transport struct {
	// InitialPeerSettings supplies authenticated settings before the connection
	// preface. See http.HTTP2Fingerprint.InitialPeerSettings. Nil is native behavior.
	InitialPeerSettings func(net.Conn) ([]Setting, error)
	// HealthCheckPayload selects opaque data for automatic idle PINGs only.
	// Nil uses native randomness. Connection snapshots copy the value.
	HealthCheckPayload *[8]byte
	// WriteBufferSize sets the connection writer buffer; zero is native default.
	WriteBufferSize int
	// RequestBodyPolicy selects upload read boundaries and DATA limits. See
	// RequestBodyInfo and http.HTTP2Fingerprint.RequestBodyPolicy.
	RequestBodyPolicy func(RequestBodyInfo) RequestBodyOptions
	// ConnectionErrorPolicy can promote a peer stream error or GOAWAY to
	// immediate connection shutdown. Nil retains native HTTP/2 handling.
	// See ConnectionErrorInfo and http.HTTP2Fingerprint.ConnectionErrorPolicy.
	ConnectionErrorPolicy func(ConnectionErrorInfo) bool
	// ConnectionClosePolicy optionally selects a final GOAWAY before close.
	// Nil preserves native behavior; see ConnectionCloseInfo.
	ConnectionClosePolicy     func(ConnectionCloseInfo) ConnectionCloseOptions
	StreamReceiveWindow       uint32
	ReceiveWindowUpdatePolicy func(ReceiveWindowUpdateInfo) bool
	// Initial HTTP/2 wire representation, preserved from the original fork.
	Settings                []Setting
	StreamID                uint32
	ConnectionFlow          uint32
	PriorityParam           PriorityParam
	PriorityFrames          []PriorityFrame
	HPACK                   *HPACKConfig
	HeaderPriority          func(PriorityRequest) PriorityParam
	ChainStreamDependencies bool

	// DialTLSContext specifies an optional dial function with context for
	// creating TLS connections for requests.
	//
	// If DialTLSContext and DialTLS is nil, tls.Dial is used.
	//
	// If the returned net.Conn has a ConnectionState method like tls.Conn,
	// it will be used to set http.Response.TLS.
	DialTLSContext func(ctx context.Context, network, addr string, cfg *tls.Config) (net.Conn, error)

	// DialTLS specifies an optional dial function for creating
	// TLS connections for requests.
	//
	// If DialTLSContext and DialTLS is nil, tls.Dial is used.
	DialTLS func(network, addr string, cfg *tls.Config) (net.Conn, error)

	// TLSClientConfig specifies the TLS configuration to use with
	// tls.Client. If nil, the default configuration is used.
	TLSClientConfig *tls.Config

	// ConnPool optionally specifies an alternate connection pool to use.
	// If nil, the default is used.
	ConnPool ClientConnPool

	// DisableCompression, if true, prevents the Transport from
	// requesting compression with an "Accept-Encoding: gzip"
	// request header when the Request contains no existing
	// Accept-Encoding value. If the Transport requests gzip on
	// its own and gets a gzipped response, it's transparently
	// decoded in the Response.Body. However, if the user
	// explicitly requested gzip it is not automatically
	// uncompressed.
	DisableCompression bool

	// AllowHTTP, if true, permits HTTP/2 requests using the insecure,
	// plain-text "http" scheme. Note that this does not enable h2c support.
	AllowHTTP bool

	// MaxHeaderListSize is the http2 SETTINGS_MAX_HEADER_LIST_SIZE to
	// send in the initial settings frame. It is how many bytes
	// of response headers are allowed. Unlike the http2 spec, zero here
	// means to use a default limit (currently 10MB). If you actually
	// want to advertise an unlimited value to the peer, Transport
	// interprets the highest possible value here (0xffffffff or 1<<32-1)
	// to mean no limit.
	MaxHeaderListSize uint32

	// MaxReadFrameSize is the http2 SETTINGS_MAX_FRAME_SIZE to send in the
	// initial settings frame. It is the size in bytes of the largest frame
	// payload that the sender is willing to receive. If 0, no setting is
	// sent, and the value is provided by the peer, which should be 16384
	// according to the spec:
	// https://datatracker.ietf.org/doc/html/rfc7540#section-6.5.2.
	// Values are bounded in the range 16k to 16M.
	MaxReadFrameSize uint32

	// MaxDecoderHeaderTableSize optionally specifies the http2
	// SETTINGS_HEADER_TABLE_SIZE to send in the initial settings frame. It
	// informs the remote endpoint of the maximum size of the header compression
	// table used to decode header blocks, in octets. If zero, the default value
	// of 4096 is used.
	MaxDecoderHeaderTableSize uint32

	// MaxEncoderHeaderTableSize optionally specifies an upper limit for the
	// header compression table used for encoding request headers. Received
	// SETTINGS_HEADER_TABLE_SIZE settings are capped at this limit. If zero,
	// the default value of 4096 is used.
	MaxEncoderHeaderTableSize uint32

	// StrictMaxConcurrentStreams controls whether the server's
	// SETTINGS_MAX_CONCURRENT_STREAMS should be respected
	// globally. If false, new TCP connections are created to the
	// server as needed to keep each under the per-connection
	// SETTINGS_MAX_CONCURRENT_STREAMS limit. If true, the
	// server's SETTINGS_MAX_CONCURRENT_STREAMS is interpreted as
	// a global limit and callers of RoundTrip block when needed,
	// waiting for their turn.
	StrictMaxConcurrentStreams bool

	// IdleConnTimeout is the maximum amount of time an idle
	// (keep-alive) connection will remain idle before closing
	// itself.
	// Zero means no limit.
	IdleConnTimeout time.Duration

	// ReadIdleTimeout is the timeout after which a health check using ping
	// frame will be carried out if no frame is received on the connection.
	// Note that a ping response will is considered a received frame, so if
	// there is no other traffic on the connection, the health check will
	// be performed every ReadIdleTimeout interval.
	// If zero, no health check is performed.
	ReadIdleTimeout time.Duration

	// PingTimeout is the timeout after which the connection will be closed
	// if a response to Ping is not received.
	// Defaults to 15s.
	PingTimeout time.Duration

	// WriteByteTimeout is the timeout after which the connection will be
	// closed no data can be written to it. The timeout begins when data is
	// available to write, and is extended whenever any bytes are written.
	WriteByteTimeout time.Duration

	// CountError, if non-nil, is called on HTTP/2 transport errors.
	// It's intended to increment a metric for monitoring, such
	// as an expvar or Prometheus metric.
	// The errType consists of only ASCII word characters.
	CountError func(errType string)
	// contains filtered or unexported fields
}

Transport is an HTTP/2 Transport.

A Transport internally caches connections to servers. It is safe for concurrent use by multiple goroutines.

func ConfigureTransports

func ConfigureTransports(t1 *http.Transport) (*Transport, error)

ConfigureTransports configures a net/http HTTP/1 Transport to use HTTP/2. It returns a new HTTP/2 Transport for further configuration. It returns an error if t1 has already been HTTP/2-enabled.

func (*Transport) CloseIdleConnections

func (t *Transport) CloseIdleConnections()

CloseIdleConnections closes any connections which were previously connected from previous requests but are now sitting idle. It does not interrupt any connections currently in use.

func (*Transport) HTTP2Connections

func (t *Transport) HTTP2Connections() []*http.HTTP2Connection

HTTP2Connections snapshots the shared native pool without dialing, reserving streams or sending frames. Custom ConnPool implementations are not inspected.

func (*Transport) HasHTTP2Connection

func (t *Transport) HasHTTP2Connection(req *http.Request) bool

HasHTTP2Connection reports whether the shared native pool has a reusable HTTP/2 session for req. It does not dial, send, reserve a stream, or touch the body. A busy session can report true. Custom ConnPool implementations report false because their ownership and admission rules are not observable here.

func (*Transport) NewClientConn

func (t *Transport) NewClientConn(c net.Conn) (*ClientConn, error)

NewClientConn creates an HTTP/2 client connection over c.

func (*Transport) Preconnect

func (t *Transport) Preconnect(req *http.Request) error

Preconnect prepares an HTTP/2 connection in the transport's normal pool without sending req or touching its body. Custom ConnPool implementations are unsupported. Dial coalescing, TLS options and connection settings are identical to RoundTrip.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip sends a request over HTTP/2 and returns its response.

func (*Transport) RoundTripOpt

func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Response, error)

RoundTripOpt is like RoundTrip, but takes options.

type UnknownFrame

type UnknownFrame = native.UnknownFrame

type WindowUpdateFrame

type WindowUpdateFrame = native.WindowUpdateFrame

Directories

Path Synopsis
Package h2c supports unencrypted HTTP/2 through both prior knowledge and HTTP/1.1 Upgrade.
Package h2c supports unencrypted HTTP/2 through both prior knowledge and HTTP/1.1 Upgrade.

Jump to

Keyboard shortcuts

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