package http2

Import Path
	github.com/imroc/req/v3/internal/http2 (on go.dev)

Dependency Relation
	imports 37 packages, and imported by one package

Involved Source Files client_conn_pool.go databuffer.go errors.go flow.go frame.go gotrack.go headermap.go http2.go pipe.go Copyright 2024 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. trace.go transport.go
Package-Level Type Names (total 28)
/* sort by: | */
ClientConn is the state of a single HTTP/2 client connection to an HTTP/2 server. 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. Close closes the client connection immediately. In-flight requests are interrupted. For a graceful shutdown, use Shutdown instead. Ping sends a PING frame to the server and waits for the ack. ReserveNewRequest is like CanTakeNewRequest but also reserves a concurrent stream in cc. The reservation is decremented on the next call to RoundTrip. (*ClientConn) RoundTrip(req *http.Request) (*http.Response, error) SetDoNotReuse marks cc as not reusable for future HTTP requests. Shutdown gracefully closes the client connection, waiting for running streams to complete. *ClientConn : github.com/prometheus/common/expfmt.Closer *ClientConn : database/sql/driver.Pinger *ClientConn : io.Closer *ClientConn : net/http.RoundTripper func ClientConnPool.GetClientConn(req *http.Request, addr string, dialOnMiss bool) (*ClientConn, error) func (*Transport).NewClientConn(c net.Conn) (*ClientConn, error) func ClientConnPool.MarkDead(*ClientConn)
ClientConnPool manages a pool of HTTP/2 client connections. ( ClientConnPool) AddConnIfNeeded(key string, t *Transport, c net.Conn) (used bool, err error) ( ClientConnPool) CloseIdleConnections() 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. ( ClientConnPool) MarkDead(*ClientConn)
ClientConnState describes the state of a ClientConn. Closed is whether the connection is closed. 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. LastIdle, if non-zero, is when the connection last transitioned to idle state. MaxConcurrentStreams is how many concurrent streams the peer advertised as acceptable. Zero means no SETTINGS frame has been received yet. StreamsActive is how many streams are active. 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. StreamsReserved is how many streams have been reserved via ClientConn.ReserveNewRequest.
ConnectionError is an error that results in the termination of the entire connection. ( ConnectionError) Error() string ConnectionError : error
A ContinuationFrame is used to continue a sequence of header block fragments. See https://httpwg.org/specs/rfc7540.html#rfc.section.6.10 FrameHeader FrameHeader Flags are the 1 byte of 8 potential bit flags per frame. They are specific to the frame type. Length is the length of the frame, not including the 9 byte header. The maximum size is one byte less than 16MB (uint24), but only frames up to 16KB are allowed without peer agreement. StreamID is which stream this frame is for. Certain frames are not stream-specific, in which case this field is 0. Type is the 1 byte frame type. There are ten standard frame types, but extension frame types may be written by WriteRawFrame and will be returned by ReadFrame (as UnknownFrame). Header returns h. It exists so FrameHeaders can be embedded in other specific frame types and implement the Frame interface. (*ContinuationFrame) HeaderBlockFragment() []byte (*ContinuationFrame) HeadersEnded() bool ( ContinuationFrame) String() string *ContinuationFrame : Frame ContinuationFrame : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer ContinuationFrame : github.com/pandatix/go-abnf.ElemItf ContinuationFrame : expvar.Var ContinuationFrame : fmt.Stringer
A DataFrame conveys arbitrary, variable-length sequences of octets associated with a stream. See https://httpwg.org/specs/rfc7540.html#rfc.section.6.1 FrameHeader FrameHeader Flags are the 1 byte of 8 potential bit flags per frame. They are specific to the frame type. Length is the length of the frame, not including the 9 byte header. The maximum size is one byte less than 16MB (uint24), but only frames up to 16KB are allowed without peer agreement. StreamID is which stream this frame is for. Certain frames are not stream-specific, in which case this field is 0. Type is the 1 byte frame type. There are ten standard frame types, but extension frame types may be written by WriteRawFrame and will be returned by ReadFrame (as UnknownFrame). Data returns the frame's data octets, not including any padding size byte or padding suffix bytes. The caller must not retain the returned memory past the next call to ReadFrame. Header returns h. It exists so FrameHeaders can be embedded in other specific frame types and implement the Frame interface. (*DataFrame) StreamEnded() bool ( DataFrame) String() string *DataFrame : Frame DataFrame : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer DataFrame : github.com/pandatix/go-abnf.ElemItf DataFrame : expvar.Var DataFrame : fmt.Stringer
An ErrCode is an unsigned 32-bit error code as defined in the HTTP/2 spec. ( ErrCode) String() string ErrCode : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer ErrCode : github.com/pandatix/go-abnf.ElemItf ErrCode : expvar.Var ErrCode : fmt.Stringer func (*Framer).WriteGoAway(maxStreamID uint32, code ErrCode, debugData []byte) error func (*Framer).WriteRSTStream(streamID uint32, code ErrCode) error const ErrCodeCancel const ErrCodeCompression const ErrCodeConnect const ErrCodeEnhanceYourCalm const ErrCodeFlowControl const ErrCodeFrameSize const ErrCodeHTTP11Required const ErrCodeInadequateSecurity const ErrCodeInternal const ErrCodeNo const ErrCodeProtocol const ErrCodeRefusedStream const ErrCodeSettingsTimeout const ErrCodeStreamClosed
Flags is a bitmask of HTTP/2 flags. The meaning of flags varies depending on the frame type. Has reports whether f contains all (0 or more) flags in v. func Flags.Has(v Flags) bool func (*Framer).WriteRawFrame(t FrameType, flags Flags, streamID uint32, payload []byte) error const FlagContinuationEndHeaders const FlagDataEndStream const FlagDataPadded const FlagHeadersEndHeaders const FlagHeadersEndStream const FlagHeadersPadded const FlagHeadersPriority const FlagPingAck const FlagPushPromiseEndHeaders const FlagPushPromisePadded const FlagSettingsAck
A Frame is the base interface implemented by all frame types. Callers will generally type-assert the specific frame type: *HeadersFrame, *SettingsFrame, *WindowUpdateFrame, etc. Frames are only valid until the next call to Framer.ReadFrame. ( Frame) Header() FrameHeader *ContinuationFrame *DataFrame *FrameHeader *GoAwayFrame *HeadersFrame MetaHeadersFrame *PingFrame *PriorityFrame *PushPromiseFrame *RSTStreamFrame *SettingsFrame *UnknownFrame *WindowUpdateFrame func (*Framer).ReadFrame() (Frame, error)
A FrameHeader is the 9 byte header of all HTTP/2 frames. See https://httpwg.org/specs/rfc7540.html#FrameHeader Flags are the 1 byte of 8 potential bit flags per frame. They are specific to the frame type. Length is the length of the frame, not including the 9 byte header. The maximum size is one byte less than 16MB (uint24), but only frames up to 16KB are allowed without peer agreement. StreamID is which stream this frame is for. Certain frames are not stream-specific, in which case this field is 0. Type is the 1 byte frame type. There are ten standard frame types, but extension frame types may be written by WriteRawFrame and will be returned by ReadFrame (as UnknownFrame). Header returns h. It exists so FrameHeaders can be embedded in other specific frame types and implement the Frame interface. ( FrameHeader) String() string *FrameHeader : Frame FrameHeader : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer FrameHeader : github.com/pandatix/go-abnf.ElemItf FrameHeader : expvar.Var FrameHeader : fmt.Stringer func ReadFrameHeader(r io.Reader) (FrameHeader, error) func Frame.Header() FrameHeader func FrameHeader.Header() FrameHeader
A Framer reads and writes Frames. AllowIllegalReads permits the Framer's ReadFrame method to return non-compliant frames or frame orders. This is for testing and permits using the Framer to test other HTTP/2 implementations' conformance to the spec. It is not compatible with ReadMetaHeaders. AllowIllegalWrites permits the Framer's Write methods to write frames that do not conform to the HTTP/2 spec. This permits using the Framer to test other HTTP/2 implementations' conformance to the spec. If false, the Write methods will prefer to return an error rather than comply. MaxHeaderListSize is the http2 MAX_HEADER_LIST_SIZE. It's used only if ReadMetaHeaders is set; 0 means a sane default (currently 16MB) If the limit is hit, MetaHeadersFrame.Truncated is set true. ReadMetaHeaders if non-nil causes ReadFrame to merge HEADERS and CONTINUATION frames together and return MetaHeadersFrame instead. ErrorDetail returns a more detailed error of the last error returned by Framer.ReadFrame. For instance, if ReadFrame returns a StreamError with code PROTOCOL_ERROR, ErrorDetail will say exactly what was invalid. ErrorDetail is not guaranteed to return a non-nil value and like the rest of the http2 package, its return value is not protected by an API compatibility promise. ErrorDetail is reset after the next call to ReadFrame. ReadFrame reads a single frame. The returned Frame is only valid until the next call to ReadFrame. If the frame is larger than previously set with SetMaxReadFrameSize, the returned error is errFrameTooLarge. Other errors may be of type ConnectionError, StreamError, or anything else from the underlying reader. If ReadFrame returns an error and a non-nil Frame, the Frame's StreamID indicates the stream responsible for the error. SetMaxReadFrameSize sets the maximum size of a frame that will be read by a subsequent call to ReadFrame. It is the caller's responsibility to advertise this limit with a SETTINGS frame. SetReuseFrames allows the Framer to reuse Frames. If called on a Framer, Frames returned by calls to ReadFrame are only valid until the next call to ReadFrame. WriteContinuation writes a CONTINUATION frame. It will perform exactly one Write to the underlying Writer. It is the caller's responsibility to not call other Write methods concurrently. writeData writes a DATA frame. It will perform exactly one Write to the underlying Writer. It is the caller's responsibility not to violate the maximum frame size and to not call other Write methods concurrently. WriteDataPadded writes a DATA frame with optional padding. If pad is nil, the padding bit is not sent. The length of pad must not exceed 255 bytes. The bytes of pad must all be zero, unless f.AllowIllegalWrites is set. It will perform exactly one Write to the underlying Writer. It is the caller's responsibility not to violate the maximum frame size and to not call other Write methods concurrently. (*Framer) WriteGoAway(maxStreamID uint32, code ErrCode, debugData []byte) error WriteHeaders writes a single HEADERS frame. This is a low-level header writing method. Encoding headers and splitting them into any necessary CONTINUATION frames is handled elsewhere. It will perform exactly one Write to the underlying Writer. It is the caller's responsibility to not call other Write methods concurrently. (*Framer) WritePing(ack bool, data [8]byte) error WritePriority writes a PRIORITY frame. It will perform exactly one Write to the underlying Writer. It is the caller's responsibility to not call other Write methods concurrently. WritePushPromise writes a single PushPromise Frame. As with Header Frames, This is the low level call for writing individual frames. Continuation frames are handled elsewhere. It will perform exactly one Write to the underlying Writer. It is the caller's responsibility to not call other Write methods concurrently. WriteRSTStream writes a RST_STREAM frame. It will perform exactly one Write to the underlying Writer. It is the caller's responsibility to not call other Write methods concurrently. WriteRawFrame writes a raw frame. This can be used to write extension frames unknown to this package. WriteSettings writes a SETTINGS frame with zero or more settings specified and the ACK bit not set. It will perform exactly one Write to the underlying Writer. It is the caller's responsibility to not call other Write methods concurrently. WriteSettingsAck writes an empty SETTINGS frame with the ACK bit set. It will perform exactly one Write to the underlying Writer. It is the caller's responsibility to not call other Write methods concurrently. WriteWindowUpdate writes a WINDOW_UPDATE frame. The increment value must be between 1 and 2,147,483,647, inclusive. If the Stream ID is zero, the window update applies to the connection as a whole. func NewFramer(w io.Writer, r io.Reader) *Framer
A FrameType is a registered frame type as defined in https://httpwg.org/specs/rfc7540.html#rfc.section.11.2 ( FrameType) String() string FrameType : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer FrameType : github.com/pandatix/go-abnf.ElemItf FrameType : expvar.Var FrameType : fmt.Stringer func (*Framer).WriteRawFrame(t FrameType, flags Flags, streamID uint32, payload []byte) error const FrameContinuation const FrameData const FrameGoAway const FrameHeaders const FramePing const FramePriority const FramePushPromise const FrameRSTStream const FrameSettings const FrameWindowUpdate
GoAwayError is returned by the Transport when the server closes the TCP connection after sending a GOAWAY frame. DebugData string ErrCode ErrCode LastStreamID uint32 ( GoAwayError) Error() string GoAwayError : error
A GoAwayFrame informs the remote peer to stop creating streams on this connection. See https://httpwg.org/specs/rfc7540.html#rfc.section.6.8 ErrCode ErrCode FrameHeader FrameHeader Flags are the 1 byte of 8 potential bit flags per frame. They are specific to the frame type. Length is the length of the frame, not including the 9 byte header. The maximum size is one byte less than 16MB (uint24), but only frames up to 16KB are allowed without peer agreement. StreamID is which stream this frame is for. Certain frames are not stream-specific, in which case this field is 0. Type is the 1 byte frame type. There are ten standard frame types, but extension frame types may be written by WriteRawFrame and will be returned by ReadFrame (as UnknownFrame). LastStreamID uint32 DebugData returns any debug data in the GOAWAY frame. Its contents are not defined. The caller must not retain the returned memory past the next call to ReadFrame. Header returns h. It exists so FrameHeaders can be embedded in other specific frame types and implement the Frame interface. ( GoAwayFrame) String() string *GoAwayFrame : Frame GoAwayFrame : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer GoAwayFrame : github.com/pandatix/go-abnf.ElemItf GoAwayFrame : expvar.Var GoAwayFrame : fmt.Stringer
A HeadersFrame is used to open a stream and additionally carries a header block fragment. FrameHeader FrameHeader Flags are the 1 byte of 8 potential bit flags per frame. They are specific to the frame type. Length is the length of the frame, not including the 9 byte header. The maximum size is one byte less than 16MB (uint24), but only frames up to 16KB are allowed without peer agreement. StreamID is which stream this frame is for. Certain frames are not stream-specific, in which case this field is 0. Type is the 1 byte frame type. There are ten standard frame types, but extension frame types may be written by WriteRawFrame and will be returned by ReadFrame (as UnknownFrame). Priority is set if FlagHeadersPriority is set in the FrameHeader. (*HeadersFrame) HasPriority() bool Header returns h. It exists so FrameHeaders can be embedded in other specific frame types and implement the Frame interface. (*HeadersFrame) HeaderBlockFragment() []byte (*HeadersFrame) HeadersEnded() bool (*HeadersFrame) StreamEnded() bool ( HeadersFrame) String() string *HeadersFrame : Frame HeadersFrame : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer HeadersFrame : github.com/pandatix/go-abnf.ElemItf HeadersFrame : expvar.Var HeadersFrame : fmt.Stringer
HeadersFrameParam are the parameters for writing a HEADERS frame. BlockFragment is part (or all) of a Header Block. EndHeaders indicates that this frame contains an entire header block and is not followed by any CONTINUATION frames. EndStream indicates that the header block is the last that the endpoint will send for the identified stream. Setting this flag causes the stream to enter one of "half closed" states. PadLength is the optional number of bytes of zeros to add to this frame. Priority, if non-zero, includes stream priority information in the HEADER frame. StreamID is the required Stream ID to initiate. func (*Framer).WriteHeaders(p HeadersFrameParam) error
A MetaHeadersFrame is the representation of one HEADERS frame and zero or more contiguous CONTINUATION frames and the decoding of their HPACK-encoded contents. This type of frame does not appear on the wire and is only returned by the Framer when Framer.ReadMetaHeaders is set. Fields are the fields contained in the HEADERS and CONTINUATION frames. The underlying slice is owned by the Framer and must not be retained after the next call to ReadFrame. Fields are guaranteed to be in the correct http2 order and not have unknown pseudo header fields or invalid header field names or values. Required pseudo header fields may be missing, however. Use the MetaHeadersFrame.Pseudo accessor method access pseudo headers. HeadersFrame *HeadersFrame HeadersFrame.FrameHeader FrameHeader Flags are the 1 byte of 8 potential bit flags per frame. They are specific to the frame type. Length is the length of the frame, not including the 9 byte header. The maximum size is one byte less than 16MB (uint24), but only frames up to 16KB are allowed without peer agreement. StreamID is which stream this frame is for. Certain frames are not stream-specific, in which case this field is 0. Type is the 1 byte frame type. There are ten standard frame types, but extension frame types may be written by WriteRawFrame and will be returned by ReadFrame (as UnknownFrame). Priority is set if FlagHeadersPriority is set in the FrameHeader. Truncated is whether the max header list size limit was hit and Fields is incomplete. The hpack decoder state is still valid, however. ( MetaHeadersFrame) HasPriority() bool Header returns h. It exists so FrameHeaders can be embedded in other specific frame types and implement the Frame interface. ( MetaHeadersFrame) HeaderBlockFragment() []byte ( MetaHeadersFrame) HeadersEnded() bool PseudoFields returns the pseudo header fields of mh. The caller does not own the returned slice. PseudoValue returns the given pseudo header field's value. The provided pseudo field should not contain the leading colon. RegularFields returns the regular (non-pseudo) header fields of mh. The caller does not own the returned slice. ( MetaHeadersFrame) StreamEnded() bool ( MetaHeadersFrame) String() string MetaHeadersFrame : Frame MetaHeadersFrame : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer MetaHeadersFrame : github.com/pandatix/go-abnf.ElemItf MetaHeadersFrame : expvar.Var MetaHeadersFrame : fmt.Stringer
A PingFrame is a mechanism for measuring a minimal round trip time from the sender, as well as determining whether an idle connection is still functional. See https://httpwg.org/specs/rfc7540.html#rfc.section.6.7 Data [8]byte FrameHeader FrameHeader Flags are the 1 byte of 8 potential bit flags per frame. They are specific to the frame type. Length is the length of the frame, not including the 9 byte header. The maximum size is one byte less than 16MB (uint24), but only frames up to 16KB are allowed without peer agreement. StreamID is which stream this frame is for. Certain frames are not stream-specific, in which case this field is 0. Type is the 1 byte frame type. There are ten standard frame types, but extension frame types may be written by WriteRawFrame and will be returned by ReadFrame (as UnknownFrame). Header returns h. It exists so FrameHeaders can be embedded in other specific frame types and implement the Frame interface. (*PingFrame) IsAck() bool ( PingFrame) String() string *PingFrame : Frame PingFrame : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer PingFrame : github.com/pandatix/go-abnf.ElemItf PingFrame : expvar.Var PingFrame : fmt.Stringer
A PriorityFrame specifies the sender-advised priority of a stream. See https://httpwg.org/specs/rfc7540.html#rfc.section.6.3 FrameHeader FrameHeader Flags are the 1 byte of 8 potential bit flags per frame. They are specific to the frame type. Length is the length of the frame, not including the 9 byte header. The maximum size is one byte less than 16MB (uint24), but only frames up to 16KB are allowed without peer agreement. StreamID is which stream this frame is for. Certain frames are not stream-specific, in which case this field is 0. Type is the 1 byte frame type. There are ten standard frame types, but extension frame types may be written by WriteRawFrame and will be returned by ReadFrame (as UnknownFrame). PriorityParam http2.PriorityParam Exclusive is whether the dependency is exclusive. StreamDep is a 31-bit stream identifier for the stream that this stream depends on. Zero means no dependency. Weight is the stream's zero-indexed weight. It should be set together with StreamDep, or neither should be set. Per the spec, "Add one to the value to obtain a weight between 1 and 256." Header returns h. It exists so FrameHeaders can be embedded in other specific frame types and implement the Frame interface. ( PriorityFrame) IsZero() bool ( PriorityFrame) String() string *PriorityFrame : Frame PriorityFrame : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer PriorityFrame : github.com/pandatix/go-abnf.ElemItf PriorityFrame : expvar.Var PriorityFrame : fmt.Stringer PriorityFrame : go.yaml.in/yaml/v3.IsZeroer PriorityFrame : gopkg.in/yaml.v3.IsZeroer
A PushPromiseFrame is used to initiate a server stream. See https://httpwg.org/specs/rfc7540.html#rfc.section.6.6 FrameHeader FrameHeader Flags are the 1 byte of 8 potential bit flags per frame. They are specific to the frame type. Length is the length of the frame, not including the 9 byte header. The maximum size is one byte less than 16MB (uint24), but only frames up to 16KB are allowed without peer agreement. StreamID is which stream this frame is for. Certain frames are not stream-specific, in which case this field is 0. Type is the 1 byte frame type. There are ten standard frame types, but extension frame types may be written by WriteRawFrame and will be returned by ReadFrame (as UnknownFrame). PromiseID uint32 Header returns h. It exists so FrameHeaders can be embedded in other specific frame types and implement the Frame interface. (*PushPromiseFrame) HeaderBlockFragment() []byte (*PushPromiseFrame) HeadersEnded() bool ( PushPromiseFrame) String() string *PushPromiseFrame : Frame PushPromiseFrame : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer PushPromiseFrame : github.com/pandatix/go-abnf.ElemItf PushPromiseFrame : expvar.Var PushPromiseFrame : fmt.Stringer
PushPromiseParam are the parameters for writing a PUSH_PROMISE frame. BlockFragment is part (or all) of a Header Block. EndHeaders indicates that this frame contains an entire header block and is not followed by any CONTINUATION frames. PadLength is the optional number of bytes of zeros to add to this frame. PromiseID is the required Stream ID which this Push Promises StreamID is the required Stream ID to initiate. func (*Framer).WritePushPromise(p PushPromiseParam) error
RoundTripOpt are options for the Transport.RoundTripOpt method. OnlyCachedConn controls whether RoundTripOpt may create a new TCP connection. If set true and no cached connection is available, RoundTripOpt will return ErrNoCachedConn. func (*Transport).RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Response, error)
A RSTStreamFrame allows for abnormal termination of a stream. See https://httpwg.org/specs/rfc7540.html#rfc.section.6.4 ErrCode ErrCode FrameHeader FrameHeader Flags are the 1 byte of 8 potential bit flags per frame. They are specific to the frame type. Length is the length of the frame, not including the 9 byte header. The maximum size is one byte less than 16MB (uint24), but only frames up to 16KB are allowed without peer agreement. StreamID is which stream this frame is for. Certain frames are not stream-specific, in which case this field is 0. Type is the 1 byte frame type. There are ten standard frame types, but extension frame types may be written by WriteRawFrame and will be returned by ReadFrame (as UnknownFrame). Header returns h. It exists so FrameHeaders can be embedded in other specific frame types and implement the Frame interface. ( RSTStreamFrame) String() string *RSTStreamFrame : Frame RSTStreamFrame : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer RSTStreamFrame : github.com/pandatix/go-abnf.ElemItf RSTStreamFrame : expvar.Var RSTStreamFrame : fmt.Stringer
A SettingsFrame conveys configuration parameters that affect how endpoints communicate, such as preferences and constraints on peer behavior. See https://httpwg.org/specs/rfc7540.html#SETTINGS FrameHeader FrameHeader Flags are the 1 byte of 8 potential bit flags per frame. They are specific to the frame type. Length is the length of the frame, not including the 9 byte header. The maximum size is one byte less than 16MB (uint24), but only frames up to 16KB are allowed without peer agreement. StreamID is which stream this frame is for. Certain frames are not stream-specific, in which case this field is 0. Type is the 1 byte frame type. There are ten standard frame types, but extension frame types may be written by WriteRawFrame and will be returned by ReadFrame (as UnknownFrame). ForeachSetting runs fn for each setting. It stops and returns the first error. HasDuplicates reports whether f contains any duplicate setting IDs. Header returns h. It exists so FrameHeaders can be embedded in other specific frame types and implement the Frame interface. (*SettingsFrame) IsAck() bool (*SettingsFrame) NumSettings() int Setting returns the setting from the frame at the given 0-based index. The index must be >= 0 and less than f.NumSettings(). ( SettingsFrame) String() string (*SettingsFrame) Value(id http2.SettingID) (v uint32, ok bool) *SettingsFrame : Frame SettingsFrame : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer SettingsFrame : github.com/pandatix/go-abnf.ElemItf SettingsFrame : expvar.Var SettingsFrame : fmt.Stringer
StreamError is an error that only affects one stream within an HTTP/2 connection. // optional additional detail Code ErrCode StreamID uint32 ( StreamError) Error() string StreamError : error
Transport is an HTTP/2 Transport. A Transport internally caches connections to servers. It is safe for concurrent use by multiple goroutines. AllowHTTP, if true, permits HTTP/2 requests using the insecure, plain-text "http" scheme. Note that this does not enable h2c support. ConnPool optionally specifies an alternate connection pool to use. If nil, the default is used. ConnectionFlow uint32 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. DialTLS specifies an optional dial function for creating TLS connections for requests. If 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. HeaderPriority http2.PriorityParam IdleConnTimeout is the maximum amount of time an idle (keep-alive) connection will remain idle before closing itself. Zero means no limit. 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. Options *transport.Options AutoDecompression, if true, enables automatic decompression of compressed responses. It is equivalent to setting the Accept-Encoding header to "gzip, deflate, br, zstd" and the Transport will handle the decompression of the response transparently, returning the uncompressed. Debugf is the optional debug function. DialContext specifies the dial function for creating unencrypted TCP connections. If DialContext is nil, then the transport dials using package net. DialContext runs concurrently with calls to RoundTrip. A RoundTrip call that initiates a dial may end up using a connection dialed previously when the earlier connection becomes idle before the later DialContext completes. DialTLSContext specifies an optional dial function for creating TLS connections for non-proxied HTTPS requests. If DialTLSContext is nil, DialContext and TLSClientConfig are used. If DialTLSContext is set, the Dial and DialContext hooks are not used for HTTPS requests and the TLSClientConfig and TLSHandshakeTimeout are ignored. The returned net.Conn is assumed to already be past the TLS handshake. 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. DisableKeepAlives, if true, disables HTTP keep-alives and will only use the connection to the server for a single HTTP request. This is unrelated to the similarly named TCP keep-alives. Options.Dump *dump.Dumper EnableH2C, if true, enables http2 over plain http without tls. ExpectContinueTimeout, if non-zero, specifies the amount of time to wait for a server's first response headers after fully writing the request headers if the request has an "Expect: 100-continue" header. Zero means no timeout and causes the body to be sent immediately, without waiting for the server to approve. This time does not include the time to send the request header. GetProxyConnectHeader optionally specifies a func to return headers to send to proxyURL during a CONNECT request to the ip:port target. If it returns an error, the Transport's RoundTrip fails with that error. It can return (nil, nil) to not add headers. If GetProxyConnectHeader is non-nil, ProxyConnectHeader is ignored. MaxConnsPerHost optionally limits the total number of connections per host, including connections in the dialing, active, and idle states. On limit violation, dials will block. Zero means no limit. MaxIdleConns controls the maximum number of idle (keep-alive) connections across all hosts. Zero means no limit. MaxIdleConnsPerHost, if non-zero, controls the maximum idle (keep-alive) connections to keep per-host. If zero, defaultMaxIdleConnsPerHost is used. MaxResponseHeaderBytes specifies a limit on how many response bytes are allowed in the server's response header. Zero means to use a default limit. OnProxyConnectResponse is called when the Transport gets an HTTP response from a proxy for a CONNECT request. It's called before the check for a 200 OK response. If it returns an error, the request fails with that error. Proxy specifies a function to return a proxy for a given Request. If the function returns a non-nil error, the request is aborted with the provided error. The proxy type is determined by the URL scheme. "http", "https", "socks5", "socks5h", "socks4", and "socks4a" are supported. If the scheme is empty, "http" is assumed. "socks5" is treated the same as "socks5h". "socks4" resolves domain names locally to IPv4; "socks4a" lets the proxy resolve domain names. SOCKS4 only supports IPv4 destinations. If the proxy URL contains a userinfo subcomponent, the proxy request will pass the username and password in a Proxy-Authorization header for HTTP proxies, or the username as the SOCKS4 user ID / SOCKS5 credentials for SOCKS proxies. If Proxy is nil or returns a nil *URL, no proxy is used. ProxyConnectHeader optionally specifies headers to send to proxies during CONNECT requests. To set the header dynamically, see GetProxyConnectHeader. ReadBufferSize specifies the size of the read buffer used when reading from the transport. If zero, a default (currently 4KB) is used. ResponseHeaderTimeout, if non-zero, specifies the amount of time to wait for a server's response headers after fully writing the request (including its body, if any). This time does not include the time to read the response body. TLSClientConfig specifies the TLS configuration to use with tls.Client. If nil, the default configuration is used. If non-nil, HTTP/2 support may not be enabled by default. TLSHandshakeContext specifies an optional dial function for tls handshake, it works even if a proxy is set, can be used to customize the tls fingerprint. TLSHandshakeTimeout specifies the maximum amount of time to wait for a TLS handshake. Zero means no timeout. WriteBufferSize specifies the size of the write buffer used when writing to the transport. If zero, a default (currently 4KB) is used. PingTimeout is the timeout after which the connection will be closed if a response to Ping is not received. Defaults to 15s. PriorityFrames []http2.PriorityFrame 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. Settings []http2.Setting 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. 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. (*Transport) AddConn(conn net.Conn, addr string) (used bool, err error) ( Transport) Clone() transport.Options 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. (*Transport) NewClientConn(c net.Conn) (*ClientConn, error) (*Transport) RoundTrip(req *http.Request) (*http.Response, error) (*Transport) RoundTripOnlyCachedConn(req *http.Request) (*http.Response, error) RoundTripOpt is like RoundTrip, but takes options. *Transport : net/http.RoundTripper func ClientConnPool.AddConnIfNeeded(key string, t *Transport, c net.Conn) (used bool, err error)
An UnknownFrame is the frame type returned when the frame type is unknown or no specific frame type parser exists. FrameHeader FrameHeader Flags are the 1 byte of 8 potential bit flags per frame. They are specific to the frame type. Length is the length of the frame, not including the 9 byte header. The maximum size is one byte less than 16MB (uint24), but only frames up to 16KB are allowed without peer agreement. StreamID is which stream this frame is for. Certain frames are not stream-specific, in which case this field is 0. Type is the 1 byte frame type. There are ten standard frame types, but extension frame types may be written by WriteRawFrame and will be returned by ReadFrame (as UnknownFrame). Header returns h. It exists so FrameHeaders can be embedded in other specific frame types and implement the Frame interface. Payload returns the frame's payload (after the header). It is not valid to call this method after a subsequent call to Framer.ReadFrame, nor is it valid to retain the returned slice. The memory is owned by the Framer and is invalidated when the next frame is read. ( UnknownFrame) String() string *UnknownFrame : Frame UnknownFrame : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer UnknownFrame : github.com/pandatix/go-abnf.ElemItf UnknownFrame : expvar.Var UnknownFrame : fmt.Stringer
A WindowUpdateFrame is used to implement flow control. See https://httpwg.org/specs/rfc7540.html#rfc.section.6.9 FrameHeader FrameHeader Flags are the 1 byte of 8 potential bit flags per frame. They are specific to the frame type. Length is the length of the frame, not including the 9 byte header. The maximum size is one byte less than 16MB (uint24), but only frames up to 16KB are allowed without peer agreement. StreamID is which stream this frame is for. Certain frames are not stream-specific, in which case this field is 0. Type is the 1 byte frame type. There are ten standard frame types, but extension frame types may be written by WriteRawFrame and will be returned by ReadFrame (as UnknownFrame). // never read with high bit set Header returns h. It exists so FrameHeaders can be embedded in other specific frame types and implement the Frame interface. ( WindowUpdateFrame) String() string *WindowUpdateFrame : Frame WindowUpdateFrame : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer WindowUpdateFrame : github.com/pandatix/go-abnf.ElemItf WindowUpdateFrame : expvar.Var WindowUpdateFrame : fmt.Stringer
Package-Level Functions (total 4)
IsNoCachedConnError reports whether err is of type noCachedConnError or its equivalent renamed type in net/http2's h2_bundle.go. Both types may coexist in the same running program.
NewFramer returns a Framer that writes frames to w and reads them from r.
ReadFrameHeader reads 9 bytes from r and returns a FrameHeader. Most users should use Framer.ReadFrame instead.
Package-Level Variables (total 3)
Package-Level Constants (total 37)
ClientPreface is the string that must be sent by new connections from clients.
const ErrCodeNo ErrCode = 0
Continuation Frame
Data Frame
Frame-specific FrameHeader flag bits.
Frame-specific FrameHeader flag bits.
Headers Frame
Frame-specific FrameHeader flag bits.
Frame-specific FrameHeader flag bits.
Ping Frame
Frame-specific FrameHeader flag bits.
Frame-specific FrameHeader flag bits.
Settings Frame
const FrameData FrameType = 0
const FramePing FrameType = 6
NextProtoTLS is the NPN/ALPN protocol negotiated during HTTP/2's TLS setup.