grpcframe

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContinuationFrame

type ContinuationFrame struct {
	http2.FrameHeader
	// contains filtered or unexported fields
}

A ContinuationFrame is used to continue a sequence of header block fragments. See http://http2.github.io/http2-spec/#rfc.section.6.10

func (*ContinuationFrame) HeaderBlockFragment

func (f *ContinuationFrame) HeaderBlockFragment() []byte

func (*ContinuationFrame) HeadersEnded

func (f *ContinuationFrame) HeadersEnded() bool

type DataFrame

type DataFrame struct {
	http2.FrameHeader
	// contains filtered or unexported fields
}

A DataFrame conveys arbitrary, variable-length sequences of octets associated with a stream. See http://http2.github.io/http2-spec/#rfc.section.6.1

func (*DataFrame) Data

func (f *DataFrame) Data() []byte

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.

func (*DataFrame) StreamEnded

func (f *DataFrame) StreamEnded() bool

type Framer

type Framer struct {

	// 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.
	AllowIllegalWrites bool

	// 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.
	AllowIllegalReads bool

	// ReadMetaHeaders if non-nil causes ReadFrame to merge
	// HEADERS and CONTINUATION frames together and return
	// MetaHeadersFrame instead.
	ReadMetaHeaders *hpack.Decoder

	// 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.
	MaxHeaderListSize uint32
	// contains filtered or unexported fields
}

A Framer reads and writes Frames.

func NewFramer

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

NewFramer returns a Framer that writes frames to w and reads them from r.

func (*Framer) ErrorDetail

func (fr *Framer) ErrorDetail() error

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.

func (*Framer) ReadFrame

func (fr *Framer) ReadFrame() (http2.Frame, error)

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.

func (*Framer) SetMaxReadFrameSize

func (fr *Framer) SetMaxReadFrameSize(v uint32)

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.

func (*Framer) SetReuseFrames

func (fr *Framer) SetReuseFrames()

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.

func (*Framer) WriteContinuation

func (fr *Framer) WriteContinuation(streamID uint32, endHeaders bool, headerBlockFragment []byte) error

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.

func (*Framer) WriteData

func (fr *Framer) WriteData(streamID uint32, endStream bool, data []byte) error

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.

func (*Framer) WriteGoAway

func (fr *Framer) WriteGoAway(maxStreamID uint32, code http2.ErrCode, debugData []byte) error

func (*Framer) WriteHeaders

func (fr *Framer) WriteHeaders(p http2.HeadersFrameParam) 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.

func (*Framer) WritePing

func (fr *Framer) WritePing(ack bool, data [8]byte) error

func (*Framer) WritePriority

func (fr *Framer) WritePriority(streamID uint32, p http2.PriorityParam) 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.

func (*Framer) WritePushPromise

func (fr *Framer) WritePushPromise(p http2.PushPromiseParam) error

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.

func (*Framer) WriteRSTStream

func (fr *Framer) WriteRSTStream(streamID uint32, code http2.ErrCode) error

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.

func (*Framer) WriteRawFrame

func (fr *Framer) WriteRawFrame(t http2.FrameType, flags http2.Flags, streamID uint32, payload []byte) error

WriteRawFrame writes a raw frame. This can be used to write extension frames unknown to this package.

func (*Framer) WriteSettings

func (fr *Framer) WriteSettings(settings ...http2.Setting) error

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.

func (*Framer) WriteSettingsAck

func (fr *Framer) WriteSettingsAck() error

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.

func (*Framer) WriteWindowUpdate

func (fr *Framer) WriteWindowUpdate(streamID, incr uint32) error

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.

type GoAwayFrame

type GoAwayFrame struct {
	http2.FrameHeader
	LastStreamID uint32
	ErrCode      http2.ErrCode
	// contains filtered or unexported fields
}

A GoAwayFrame informs the remote peer to stop creating streams on this connection. See http://http2.github.io/http2-spec/#rfc.section.6.8

func (*GoAwayFrame) DebugData

func (f *GoAwayFrame) DebugData() []byte

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.

type HeadersFrame

type HeadersFrame struct {
	http2.FrameHeader

	// Priority is set if FlagHeadersPriority is set in the FrameHeader.
	Priority http2.PriorityParam
	// contains filtered or unexported fields
}

A HeadersFrame is used to open a stream and additionally carries a header block fragment.

func (*HeadersFrame) HasPriority

func (f *HeadersFrame) HasPriority() bool

func (*HeadersFrame) HeaderBlockFragment

func (f *HeadersFrame) HeaderBlockFragment() []byte

func (*HeadersFrame) HeadersEnded

func (f *HeadersFrame) HeadersEnded() bool

func (*HeadersFrame) StreamEnded

func (f *HeadersFrame) StreamEnded() bool

type MetaHeadersFrame

type MetaHeadersFrame struct {
	*HeadersFrame

	// 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.
	Fields []hpack.HeaderField

	// Truncated is whether the max header list size limit was hit
	// and Fields is incomplete. The hpack decoder state is still
	// valid, however.
	Truncated bool
}

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.

func (*MetaHeadersFrame) PseudoFields

func (mh *MetaHeadersFrame) PseudoFields() []hpack.HeaderField

PseudoFields returns the pseudo header fields of mh. The caller does not own the returned slice.

func (*MetaHeadersFrame) PseudoValue

func (mh *MetaHeadersFrame) PseudoValue(pseudo string) string

PseudoValue returns the given pseudo header field's value. The provided pseudo field should not contain the leading colon.

func (*MetaHeadersFrame) RegularFields

func (mh *MetaHeadersFrame) RegularFields() []hpack.HeaderField

RegularFields returns the regular (non-pseudo) header fields of mh. The caller does not own the returned slice.

type PushPromiseFrame

type PushPromiseFrame struct {
	http2.FrameHeader
	PromiseID uint32
	// contains filtered or unexported fields
}

A PushPromiseFrame is used to initiate a server stream. See http://http2.github.io/http2-spec/#rfc.section.6.6

func (*PushPromiseFrame) HeaderBlockFragment

func (f *PushPromiseFrame) HeaderBlockFragment() []byte

func (*PushPromiseFrame) HeadersEnded

func (f *PushPromiseFrame) HeadersEnded() bool

type SettingsFrame

type SettingsFrame struct {
	http2.FrameHeader
	// contains filtered or unexported fields
}

A SettingsFrame conveys configuration parameters that affect how endpoints communicate, such as preferences and constraints on peer behavior.

See http://http2.github.io/http2-spec/#SETTINGS

func (*SettingsFrame) ForeachSetting

func (f *SettingsFrame) ForeachSetting(fn func(http2.Setting) error) error

ForeachSetting runs fn for each setting. It stops and returns the first error.

func (*SettingsFrame) HasDuplicates

func (f *SettingsFrame) HasDuplicates() bool

HasDuplicates reports whether f contains any duplicate setting IDs.

func (*SettingsFrame) IsAck

func (f *SettingsFrame) IsAck() bool

func (*SettingsFrame) NumSettings

func (f *SettingsFrame) NumSettings() int

func (*SettingsFrame) Setting

func (f *SettingsFrame) Setting(i int) http2.Setting

Setting returns the setting from the frame at the given 0-based index. The index must be >= 0 and less than f.NumSettings().

func (*SettingsFrame) Value

func (f *SettingsFrame) Value(id http2.SettingID) (v uint32, ok bool)

type UnknownFrame

type UnknownFrame struct {
	http2.FrameHeader
	// contains filtered or unexported fields
}

An UnknownFrame is the frame type returned when the frame type is unknown or no specific frame type parser exists.

func (*UnknownFrame) Payload

func (f *UnknownFrame) Payload() []byte

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.

Jump to

Keyboard shortcuts

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