bfe_spdy

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeSynStream    ControlFrameType = 0x0001
	TypeSynReply                      = 0x0002
	TypeRstStream                     = 0x0003
	TypeSettings                      = 0x0004
	TypePing                          = 0x0006
	TypeGoAway                        = 0x0007
	TypeHeaders                       = 0x0008
	TypeWindowUpdate                  = 0x0009
)
View Source
const (
	ControlFlagFin                   ControlFlags = 0x01
	ControlFlagUnidirectional                     = 0x02
	ControlFlagSettingsClearSettings              = 0x01
)
View Source
const (
	UnlowercasedHeaderName     ErrorCode = "header was not lowercased"
	DuplicateHeaders                     = "multiple headers with same name"
	WrongCompressedPayloadSize           = "compressed payload size was incorrect"
	UnknownFrameType                     = "unknown frame type"
	InvalidControlFrame                  = "invalid control frame"
	InvalidDataFrame                     = "invalid data frame"
	InvalidHeaderPresent                 = "frame contained invalid header"
	ZeroStreamId                         = "stream id zero is disallowed"
	ErrTooLongUrl                        = "url is too long"
)
View Source
const (
	ConnTag timeoutTag = iota
	ReadStreamTag
	WriteStreamTag
)
View Source
const MaxDataLength = 1<<24 - 1

MaxDataLength is the maximum number of bytes that can be stored in one frame.

View Source
const MaxFrameSize = 1<<24 - 1
View Source
const MaxNumHeaders = 1024
View Source
const MaxNumSettings = 1024
View Source
const MinMaxFrameSize = 1 << 14
View Source
const (
	// NextProtoTLS is the NPN/ALPN protocol negotiated during SPDY's TLS setup.
	NextProtoTLS = "spdy/3.1"
)
View Source
const Version = 3

Version is the protocol version number that this package implements (spdy3.1/spdy3).

Variables

View Source
var VerboseLogs = false

Functions

func CloseConn

func CloseConn(body io.ReadCloser)

CloseConn close underlying connection for request

func NewProtoHandler

func NewProtoHandler(conf *Server) func(*http.Server, *tls.Conn, http.Handler)

NewProtoHandler creates TLS application level protocol handler for spdy

func SetConnTimeout

func SetConnTimeout(body *RequestBody, d time.Duration)

func SetFlowLimiter

func SetFlowLimiter(limiter http.FlowLimiter)

SetFlowLimiter init flow limiter for spdy

func SetReadStreamTimeout

func SetReadStreamTimeout(body *RequestBody, d time.Duration)

func SetWriteStreamTimeout

func SetWriteStreamTimeout(body *RequestBody, d time.Duration)

Types

type ConnectionError

type ConnectionError RstStreamStatus

ConnectionError is an error that results in the termination of the entire connection.

func (ConnectionError) Error

func (e ConnectionError) Error() string

type ControlFlags

type ControlFlags uint8

ControlFlags are the flags that can be set on a control frame.

type ControlFrameHeader

type ControlFrameHeader struct {
	Flags ControlFlags
	// contains filtered or unexported fields
}

ControlFrameHeader contains all the fields in a control frame header, in its unpacked in-memory representation.

type ControlFrameType

type ControlFrameType uint16

ControlFrameType stores the type field in a control frame header.

type DataFlags

type DataFlags uint8

DataFlags are the flags that can be set on a data frame.

const (
	DataFlagFin DataFlags = 0x01
)

type DataFrame

type DataFrame struct {
	// Note, high bit is the "Control" bit. Should be 0 for data frames.
	StreamId StreamId
	Flags    DataFlags
	Data     []byte // payload data of this frame
}

DataFrame is the unpacked, in-memory representation of a DATA frame.

func (*DataFrame) StreamEnded

func (f *DataFrame) StreamEnded() bool

func (*DataFrame) String

func (f *DataFrame) String() string

type Error

type Error struct {
	Err      ErrorCode
	StreamId StreamId
}

Error contains both the type of error and additional values. StreamId is 0 if Error is not associated with a stream.

func (*Error) Error

func (e *Error) Error() string

type ErrorCode

type ErrorCode string

ErrorCode represents SPDY specific error.

type FinFrame

type FinFrame struct{}

FinFrame is the special frame for finish connection.

type FlushFrame

type FlushFrame struct{}

FlushFrame is the special frame for flush connection buffer.

type Frame

type Frame interface {
	// contains filtered or unexported methods
}

Frame is a single SPDY frame in its unpacked in-memory representation. Use Framer to read and write it.

type Framer

type Framer struct {

	// max uri size
	MaxHeaderUriSize uint32
	// contains filtered or unexported fields
}

Framer handles serializing/deserializing SPDY frames, including compressing/ decompressing payloads.

func NewFramer

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

NewFramer allocates a new Framer for a given SPDY connection, represented by a io.Writer and io.Reader. Note that Framer will read and write individual fields from/to the Reader and Writer, so the caller should pass in an appropriately buffered implementation to optimize performance.

func (*Framer) ReadFrame

func (f *Framer) ReadFrame() (frame Frame, err error)

ReadFrame reads SPDY encoded data and returns a decompressed Frame.

func (*Framer) ReleaseWriter

func (f *Framer) ReleaseWriter()

func (*Framer) WriteFrame

func (f *Framer) WriteFrame(frame Frame) error

WriteFrame writes a frame.

type GoAwayFrame

type GoAwayFrame struct {
	CFHeader         ControlFrameHeader
	LastGoodStreamId StreamId // last stream id which was accepted by sender
	Status           GoAwayStatus
}

GoAwayFrame is the unpacked, in-memory representation of a GOAWAY frame.

type GoAwayStatus

type GoAwayStatus uint32

GoAwayStatus represents the status in a GoAwayFrame.

const (
	GoAwayOK GoAwayStatus = iota
	GoAwayProtocolError
	GoAwayInternalError
)

type HeadersFrame

type HeadersFrame struct {
	CFHeader ControlFrameHeader
	StreamId StreamId
	Headers  http.Header
}

HeadersFrame is the unpacked, in-memory representation of a HEADERS frame.

type PanicFrame

type PanicFrame struct{}

PanicFrame is the special frame for reset stream with panic.

type PingFrame

type PingFrame struct {
	CFHeader ControlFrameHeader
	Id       uint32 // unique id for this ping, from server is even, from client is odd.
}

PingFrame is the unpacked, in-memory representation of a PING frame.

type RequestBody

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

func (*RequestBody) Close

func (b *RequestBody) Close() error

func (*RequestBody) Eof

func (b *RequestBody) Eof() bool

Eof check whether without entity body

func (*RequestBody) Read

func (b *RequestBody) Read(p []byte) (n int, err error)

type RstStreamFrame

type RstStreamFrame struct {
	CFHeader ControlFrameHeader
	StreamId StreamId
	Status   RstStreamStatus
}

RstStreamFrame is the unpacked, in-memory representation of a RST_STREAM frame.

type RstStreamStatus

type RstStreamStatus uint32

RstStreamStatus represents the status that led to a RST_STREAM.

const (
	ProtocolError RstStreamStatus = iota + 1
	InvalidStream
	RefusedStream
	UnsupportedVersion
	Cancel
	InternalError
	FlowControlError
	StreamInUse
	StreamAlreadyClosed
	InvalidCredentials
	FrameTooLarge
)

type Server

type Server struct {
	// 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 SPDY spec's recommendations.
	MaxConcurrentStreams 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
}

type SettingsFlag

type SettingsFlag uint8

SettingsFlag represents a flag in a SETTINGS frame.

const (
	FlagSettingsPersistValue SettingsFlag = 0x1
	FlagSettingsPersisted                 = 0x2
)

type SettingsFlagIdValue

type SettingsFlagIdValue struct {
	Flag  SettingsFlag
	Id    SettingsId
	Value uint32
}

SettingsFlagIdValue is the unpacked, in-memory representation of the combined flag/id/value for a setting in a SETTINGS frame.

type SettingsFrame

type SettingsFrame struct {
	CFHeader     ControlFrameHeader
	FlagIdValues []SettingsFlagIdValue
}

SettingsFrame is the unpacked, in-memory representation of a SPDY SETTINGS frame.

type SettingsId

type SettingsId uint32

SettingsId represents the id of an id/value pair in a SETTINGS frame.

const (
	SettingsUploadBandwidth SettingsId = iota + 1
	SettingsDownloadBandwidth
	SettingsRoundTripTime
	SettingsMaxConcurrentStreams
	SettingsCurrentCwnd
	SettingsDownloadRetransRate
	SettingsInitialWindowSize
	SettingsClientCretificateVectorSize
)

type SpdyState

type SpdyState struct {
	SpdyTimeoutConn            *metrics.Counter
	SpdyTimeoutReadStream      *metrics.Counter
	SpdyTimeoutWriteStream     *metrics.Counter
	SpdyErrInvalidSynStream    *metrics.Counter
	SpdyErrInvalidDataStream   *metrics.Counter
	SpdyErrFlowControl         *metrics.Counter
	SpdyErrBadRequest          *metrics.Counter
	SpdyErrStreamAlreadyClosed *metrics.Counter
	SpdyErrStreamCancel        *metrics.Counter
	SpdyErrMaxStreamPerConn    *metrics.Counter
	SpdyErrGotReset            *metrics.Counter
	SpdyErrNewFramer           *metrics.Counter
	SpdyUnknownFrame           *metrics.Counter
	SpdyPanicConn              *metrics.Counter
	SpdyPanicStream            *metrics.Counter
	SpdyReqHeaderCompressSize  *metrics.Counter
	SpdyReqHeaderOriginalSize  *metrics.Counter
	SpdyResHeaderCompressSize  *metrics.Counter
	SpdyResHeaderOriginalSize  *metrics.Counter
	SpdyReqOverload            *metrics.Counter
	SpdyConnOverload           *metrics.Counter
}

func GetSpdyState

func GetSpdyState() *SpdyState

type StreamError

type StreamError struct {
	StreamID uint32
	Code     RstStreamStatus
}

StreamError is an error that only affects one stream within an spdy connection.

func (StreamError) Error

func (e StreamError) Error() string

type StreamId

type StreamId uint32

StreamId represents a 31-bit value identifying the stream.

type SynReplyFrame

type SynReplyFrame struct {
	CFHeader ControlFrameHeader
	StreamId StreamId
	Headers  http.Header
}

SynReplyFrame is the unpacked, in-memory representation of a SYN_REPLY frame.

func (*SynReplyFrame) StreamEnded

func (f *SynReplyFrame) StreamEnded() bool

type SynStreamFrame

type SynStreamFrame struct {
	CFHeader             ControlFrameHeader
	StreamId             StreamId
	AssociatedToStreamId StreamId // stream id for a stream which this stream is associated to
	Priority             uint8    // priority of this frame (3-bit)
	Slot                 uint8    // index in the server's credential vector of the client certificate
	Headers              http.Header
}

SynStreamFrame is the unpacked, in-memory representation of a SYN_STREAM frame.

func (*SynStreamFrame) StreamEnded

func (f *SynStreamFrame) StreamEnded() bool

type WindowUpdateFrame

type WindowUpdateFrame struct {
	CFHeader        ControlFrameHeader
	StreamId        StreamId
	DeltaWindowSize uint32 // additional number of bytes to existing window size
}

WindowUpdateFrame is the unpacked, in-memory representation of a WINDOW_UPDATE frame.

Jump to

Keyboard shortcuts

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