Documentation ¶
Index ¶
- Constants
- Variables
- func ConfigureClient(c *fasthttp.HostClient, opts ClientOpts) error
- func Handshake(preface bool, bw *bufio.Writer, st *Settings, maxWin int32) error
- func HuffmanDecode(dst, src []byte) ([]byte, error)
- func HuffmanEncode(dst, src []byte) []byte
- func ReadPreface(br io.Reader) bool
- func ReleaseFrame(fr Frame)
- func ReleaseFrameHeader(fr *FrameHeader)
- func ReleaseHPACK(hp *HPACK)
- func ReleaseHeaderField(hf *HeaderField)
- func ToLower(b []byte) []byte
- func WritePreface(wr io.Writer) error
- type Client
- type ClientOpts
- type Conn
- type ConnOpts
- type Continuation
- func (c *Continuation) AppendHeader(b []byte)
- func (c *Continuation) CopyTo(cc *Continuation)
- func (c *Continuation) Deserialize(fr *FrameHeader) error
- func (c *Continuation) EndHeaders() bool
- func (c *Continuation) Headers() []byte
- func (c *Continuation) Reset()
- func (c *Continuation) Serialize(fr *FrameHeader)
- func (c *Continuation) SetEndHeaders(value bool)
- func (c *Continuation) SetHeader(b []byte)
- func (c *Continuation) Type() FrameType
- func (c *Continuation) Write(b []byte) (int, error)
- type Ctx
- type Data
- func (data *Data) Append(b []byte)
- func (data *Data) CopyTo(d *Data)
- func (data *Data) Data() []byte
- func (data *Data) Deserialize(fr *FrameHeader) error
- func (data *Data) EndStream() bool
- func (data *Data) Len() int
- func (data *Data) Padding() bool
- func (data *Data) Reset()
- func (data *Data) Serialize(fr *FrameHeader)
- func (data *Data) SetData(b []byte)
- func (data *Data) SetEndStream(value bool)
- func (data *Data) SetPadding(value bool)
- func (data *Data) Type() FrameType
- func (data *Data) Write(b []byte) (int, error)
- type Dialer
- type Error
- type ErrorCode
- type Frame
- type FrameFlags
- type FrameHeader
- func (f *FrameHeader) Body() Frame
- func (f *FrameHeader) Flags() FrameFlags
- func (f *FrameHeader) Len() int
- func (f *FrameHeader) MaxLen() uint32
- func (f *FrameHeader) ReadFrom(br *bufio.Reader) (int64, error)
- func (f *FrameHeader) Reset()
- func (f *FrameHeader) SetBody(fr Frame)
- func (f *FrameHeader) SetFlags(flags FrameFlags)
- func (f *FrameHeader) SetStream(stream uint32)
- func (f *FrameHeader) Stream() uint32
- func (f *FrameHeader) Type() FrameType
- func (f *FrameHeader) WriteTo(w *bufio.Writer) (wb int64, err error)
- type FrameType
- type FrameWithHeaders
- type GoAway
- func (ga *GoAway) Code() ErrorCode
- func (ga *GoAway) Copy() *GoAway
- func (ga *GoAway) CopyTo(other *GoAway)
- func (ga *GoAway) Data() []byte
- func (ga *GoAway) Deserialize(fr *FrameHeader) (err error)
- func (ga *GoAway) Error() string
- func (ga *GoAway) Reset()
- func (ga *GoAway) Serialize(fr *FrameHeader)
- func (ga *GoAway) SetCode(code ErrorCode)
- func (ga *GoAway) SetData(b []byte)
- func (ga *GoAway) SetStream(stream uint32)
- func (ga *GoAway) Stream() uint32
- func (ga *GoAway) Type() FrameType
- type HPACK
- func (hp *HPACK) AppendHeader(dst []byte, hf *HeaderField, store bool) []byte
- func (hp *HPACK) AppendHeaderField(h *Headers, hf *HeaderField, store bool)
- func (hp *HPACK) DynamicSize() (n uint32)
- func (hp *HPACK) Next(hf *HeaderField, b []byte) ([]byte, error)
- func (hp *HPACK) Reset()
- func (hp *HPACK) SetMaxTableSize(size uint32)
- type HeaderField
- func (hf *HeaderField) AppendBytes(dst []byte) []byte
- func (hf *HeaderField) CopyTo(other *HeaderField)
- func (hf *HeaderField) Empty() bool
- func (hf *HeaderField) IsPseudo() bool
- func (hf *HeaderField) IsSensible() bool
- func (hf *HeaderField) Key() string
- func (hf *HeaderField) KeyBytes() []byte
- func (hf *HeaderField) Reset()
- func (hf *HeaderField) Set(k, v string)
- func (hf *HeaderField) SetBytes(k, v []byte)
- func (hf *HeaderField) SetKey(key string)
- func (hf *HeaderField) SetKeyBytes(key []byte)
- func (hf *HeaderField) SetValue(value string)
- func (hf *HeaderField) SetValueBytes(value []byte)
- func (hf *HeaderField) Size() uint32
- func (hf *HeaderField) String() string
- func (hf *HeaderField) Value() string
- func (hf *HeaderField) ValueBytes() []byte
- type Headers
- func (h *Headers) AppendHeaderField(hp *HPACK, hf *HeaderField, store bool)
- func (h *Headers) AppendRawHeaders(b []byte)
- func (h *Headers) CopyTo(h2 *Headers)
- func (h *Headers) Deserialize(frh *FrameHeader) error
- func (h *Headers) EndHeaders() bool
- func (h *Headers) EndStream() bool
- func (h *Headers) Headers() []byte
- func (h *Headers) Padding() bool
- func (h *Headers) Reset()
- func (h *Headers) Serialize(frh *FrameHeader)
- func (h *Headers) SetEndHeaders(value bool)
- func (h *Headers) SetEndStream(value bool)
- func (h *Headers) SetHeaders(b []byte)
- func (h *Headers) SetPadding(value bool)
- func (h *Headers) SetStream(stream uint32)
- func (h *Headers) SetWeight(w byte)
- func (h *Headers) Stream() uint32
- func (h *Headers) Type() FrameType
- func (h *Headers) Weight() byte
- type Ping
- func (p *Ping) CopyTo(other *Ping)
- func (p *Ping) Data() []byte
- func (p *Ping) DataAsTime() time.Time
- func (p *Ping) Deserialize(frh *FrameHeader) error
- func (p *Ping) IsAck() bool
- func (p *Ping) Reset()
- func (p *Ping) Serialize(fr *FrameHeader)
- func (p *Ping) SetAck(ack bool)
- func (p *Ping) SetCurrentTime()
- func (p *Ping) SetData(b []byte)
- func (p *Ping) Type() FrameType
- func (p *Ping) Write(b []byte) (n int, err error)
- type Priority
- func (pry *Priority) CopyTo(p *Priority)
- func (pry *Priority) Deserialize(fr *FrameHeader) (err error)
- func (pry *Priority) Reset()
- func (pry *Priority) Serialize(fr *FrameHeader)
- func (pry *Priority) SetStream(stream uint32)
- func (pry *Priority) SetWeight(w byte)
- func (pry *Priority) Stream() uint32
- func (pry *Priority) Type() FrameType
- func (pry *Priority) Weight() byte
- type PushPromise
- type RstStream
- func (rst *RstStream) Code() ErrorCode
- func (rst *RstStream) CopyTo(r *RstStream)
- func (rst *RstStream) Deserialize(fr *FrameHeader) error
- func (rst *RstStream) Error() error
- func (rst *RstStream) Reset()
- func (rst *RstStream) Serialize(fr *FrameHeader)
- func (rst *RstStream) SetCode(code ErrorCode)
- func (rst *RstStream) Type() FrameType
- type Server
- type ServerConfig
- type Settings
- func (st *Settings) CopyTo(st2 *Settings)
- func (st *Settings) Deserialize(fr *FrameHeader) error
- func (st *Settings) Encode()
- func (st *Settings) HeaderTableSize() uint32
- func (st *Settings) IsAck() bool
- func (st *Settings) MaxConcurrentStreams() uint32
- func (st *Settings) MaxFrameSize() uint32
- func (st *Settings) MaxHeaderListSize() uint32
- func (st *Settings) MaxWindowSize() uint32
- func (st *Settings) Push() bool
- func (st *Settings) Read(d []byte) error
- func (st *Settings) Reset()
- func (st *Settings) Serialize(fr *FrameHeader)
- func (st *Settings) SetAck(ack bool)
- func (st *Settings) SetHeaderTableSize(size uint32)
- func (st *Settings) SetMaxConcurrentStreams(streams uint32)
- func (st *Settings) SetMaxFrameSize(size uint32)
- func (st *Settings) SetMaxHeaderListSize(size uint32)
- func (st *Settings) SetMaxWindowSize(size uint32)
- func (st *Settings) SetPush(value bool)
- func (st *Settings) Type() FrameType
- type Stream
- func (s *Stream) Ctx() *fasthttp.RequestCtx
- func (s *Stream) ID() uint32
- func (s *Stream) IncrWindow(win int32)
- func (s *Stream) SetData(ctx *fasthttp.RequestCtx)
- func (s *Stream) SetID(id uint32)
- func (s *Stream) SetState(state StreamState)
- func (s *Stream) SetWindow(win int32)
- func (s *Stream) State() StreamState
- func (s *Stream) Window() int32
- type StreamState
- type Streams
- type WindowUpdate
- func (wu *WindowUpdate) CopyTo(w *WindowUpdate)
- func (wu *WindowUpdate) Deserialize(fr *FrameHeader) error
- func (wu *WindowUpdate) Increment() int
- func (wu *WindowUpdate) Reset()
- func (wu *WindowUpdate) Serialize(fr *FrameHeader)
- func (wu *WindowUpdate) SetIncrement(increment int)
- func (wu *WindowUpdate) Type() FrameType
- type WriteError
Constants ¶
const ( DefaultPingInterval = time.Second * 3 DefaultMaxResponseTime = time.Minute )
const ( HeaderTableSize uint16 = 0x1 EnablePush uint16 = 0x2 MaxConcurrentStreams uint16 = 0x3 MaxWindowSize uint16 = 0x4 MaxFrameSize uint16 = 0x5 MaxHeaderListSize uint16 = 0x6 )
FrameSettings string values (https://httpwg.org/specs/rfc7540.html#SettingValues)
const ( // H2TLSProto is the string used in ALPN-TLS negotiation. H2TLSProto = "h2" // H2Clean is the string used in HTTP headers by the client to upgrade the connection. H2Clean = "h2c" )
const ( // DefaultFrameSize FrameHeader default size // http://httpwg.org/specs/rfc7540.html#FrameHeader DefaultFrameSize = 9 )
Variables ¶
var ( // ErrUnknownFrameType This error codes must be used with FrameGoAway. ErrUnknownFrameType = NewError( ProtocolError, "unknown frame type") ErrMissingBytes = NewError( ProtocolError, "missing payload bytes. Need more") ErrPayloadExceeds = NewError( FrameSizeError, "FrameHeader payload exceeds the negotiated maximum size") ErrCompression = NewGoAwayError( CompressionError, "Compression error") )
var ( ErrUnexpectedSize = errors.New("unexpected size") ErrDynamicUpdate = errors.New("dynamic update received after the first header block") ErrDynamicUpdateMaxTableSize = errors.New("dynamic update is over the max table") )
var ( StringPath = []byte(":path") StringStatus = []byte(":status") StringAuthority = []byte(":authority") StringScheme = []byte(":scheme") StringMethod = []byte(":method") StringServer = []byte("server") StringContentLength = []byte("content-length") StringContentType = []byte("content-type") StringUserAgent = []byte("user-agent") StringGzip = []byte("gzip") StringGET = []byte("GET") StringHEAD = []byte("HEAD") StringPOST = []byte("POST") StringHTTP2 = []byte("HTTP/2") )
var ErrNotAvailableStreams = errors.New("ran out of available streams")
var ErrRequestCanceled = errors.New("request timed out")
var ErrServerSupport = errors.New("server doesn't support HTTP/2")
ErrServerSupport indicates whether the server supports HTTP/2 or not.
var ErrStreamNotReady = errors.New("stream hasn't been created")
var ErrTimeout = errors.New("server is not replying to pings")
Functions ¶
func ConfigureClient ¶
func ConfigureClient(c *fasthttp.HostClient, opts ClientOpts) error
ConfigureClient configures the fasthttp.HostClient to run over HTTP/2.
func Handshake ¶
Handshake performs an HTTP/2 handshake. That means, it will send the preface if `preface` is true, send a settings frame and a window update frame (for the connection's window). TODO: explain more
func HuffmanDecode ¶
HuffmanDecode decodes src into dst using Huffman codes.
src and dst must not point to the same address.
func HuffmanEncode ¶
HuffmanEncode encodes src into dst using Huffman algorithm.
src and dst must not point to the same address.
func ReadPreface ¶
ReadPreface reads the connection initialisation preface.
func ReleaseFrame ¶
func ReleaseFrame(fr Frame)
func ReleaseFrameHeader ¶
func ReleaseFrameHeader(fr *FrameHeader)
ReleaseFrameHeader reset and puts fr to the pool.
func ReleaseHeaderField ¶
func ReleaseHeaderField(hf *HeaderField)
ReleaseHeaderField puts HeaderField to the pool.
func WritePreface ¶
WritePreface writes HTTP/2 preface to the wr.
Types ¶
type ClientOpts ¶
type ClientOpts struct { // PingInterval defines the interval in which the client will ping the server. // // An interval of 0 will make the library to use DefaultPingInterval. Because ping intervals can't be disabled. PingInterval time.Duration // MaxResponseTime defines a timeout to wait for the server's response. // If the server doesn't reply within MaxResponseTime the stream will be canceled. // // If MaxResponseTime is 0, DefaultMaxResponseTime will be used. // If MaxResponseTime is <0, the max response timeout check will be disabled. MaxResponseTime time.Duration // OnRTT is assigned to every client after creation, and the handler // will be called after every RTT measurement (after receiving a PONG message). OnRTT func(time.Duration) }
ClientOpts defines the client options for the HTTP/2 connection.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn represents a raw HTTP/2 connection over TLS + TCP.
func NewConn ¶
NewConn returns a new HTTP/2 connection. To start using the connection you need to call Handshake.
func (*Conn) CanOpenStream ¶
CanOpenStream returns whether the client will be able to open a new stream or not.
func (*Conn) Cancel ¶
Cancel will try to cancel the request.
Cancel can only return ErrStreamNotReady when the cancel is performed before the stream is created.
func (*Conn) Close ¶
Close closes the connection gracefully, sending a GoAway message and then closing the underlying TCP connection.
func (*Conn) Handshake ¶
Handshake will perform the necessary handshake to establish the connection with the server. If an error is returned you can assume the TCP connection has been closed.
func (*Conn) LastErr ¶
LastErr returns the last registered error in case the connection was closed by the server.
func (*Conn) SetOnDisconnect ¶
SetOnDisconnect sets the callback that will fire when the HTTP/2 connection is closed.
type ConnOpts ¶
type ConnOpts struct { // PingInterval defines the interval in which the client will ping the server. // // An interval of <=0 will make the library to use DefaultPingInterval. Because ping intervals can't be disabled PingInterval time.Duration // DisablePingChecking ... DisablePingChecking bool // OnDisconnect is a callback that fires when the Conn disconnects. OnDisconnect func(c *Conn) }
ConnOpts defines the connection options.
type Continuation ¶
type Continuation struct {
// contains filtered or unexported fields
}
Continuation represents the Continuation frame.
Continuation frame can carry raw headers and/or the EndHeaders flag.
https://tools.ietf.org/html/rfc7540#section-6.10
func (*Continuation) AppendHeader ¶
func (c *Continuation) AppendHeader(b []byte)
AppendHeader appends the contents of `b` into the header.
func (*Continuation) CopyTo ¶
func (c *Continuation) CopyTo(cc *Continuation)
func (*Continuation) Deserialize ¶
func (c *Continuation) Deserialize(fr *FrameHeader) error
func (*Continuation) EndHeaders ¶
func (c *Continuation) EndHeaders() bool
func (*Continuation) Headers ¶
func (c *Continuation) Headers() []byte
Headers returns Header bytes.
func (*Continuation) Reset ¶
func (c *Continuation) Reset()
func (*Continuation) Serialize ¶
func (c *Continuation) Serialize(fr *FrameHeader)
func (*Continuation) SetEndHeaders ¶
func (c *Continuation) SetEndHeaders(value bool)
func (*Continuation) SetHeader ¶
func (c *Continuation) SetHeader(b []byte)
func (*Continuation) Type ¶
func (c *Continuation) Type() FrameType
type Ctx ¶
type Ctx struct { Request *fasthttp.Request Response *fasthttp.Response Err chan error // contains filtered or unexported fields }
Ctx represents a context for a stream. Every stream is related to a context.
type Data ¶
type Data struct {
// contains filtered or unexported fields
}
Data defines a FrameData
Data frames can have the following flags: END_STREAM PADDED
https://tools.ietf.org/html/rfc7540#section-6.1
func (*Data) Deserialize ¶
func (data *Data) Deserialize(fr *FrameHeader) error
func (*Data) Serialize ¶
func (data *Data) Serialize(fr *FrameHeader)
func (*Data) SetEndStream ¶
func (*Data) SetPadding ¶
SetPadding sets hasPaddingding to the data if true. If false the data won't be hasPaddingded.
type Dialer ¶
type Dialer struct { // Addr is the server's address in the form: `host:port`. Addr string // TLSConfig is the tls configuration. // // If TLSConfig is nil, a default one will be defined on the Dial call. TLSConfig *tls.Config // PingInterval defines the interval in which the client will ping the server. // // An interval of 0 will make the library to use DefaultPingInterval. Because ping intervals can't be disabled. PingInterval time.Duration // NetDial defines the callback for establishing new connection to the host. // Default Dial is used if not set. NetDial fasthttp.DialFunc }
Dialer allows creating HTTP/2 connections by specifying an address and tls configuration.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error defines the HTTP/2 errors, composed by the code and debug data.
func NewGoAwayError ¶
func NewResetStreamError ¶
type ErrorCode ¶
type ErrorCode uint32
ErrorCode defines the HTTP/2 error codes:
Error codes are defined here http://httpwg.org/specs/rfc7540.html#ErrorCodes
Errors must be uint32 because of FrameReset.
const ( NoError ErrorCode = 0x0 ProtocolError ErrorCode = 0x1 InternalError ErrorCode = 0x2 FlowControlError ErrorCode = 0x3 SettingsTimeoutError ErrorCode = 0x4 StreamClosedError ErrorCode = 0x5 FrameSizeError ErrorCode = 0x6 RefusedStreamError ErrorCode = 0x7 StreamCanceled ErrorCode = 0x8 CompressionError ErrorCode = 0x9 ConnectionError ErrorCode = 0xa EnhanceYourCalm ErrorCode = 0xb InadequateSecurity ErrorCode = 0xc HTTP11Required ErrorCode = 0xd )
type Frame ¶
type Frame interface { Type() FrameType Reset() Serialize(*FrameHeader) Deserialize(*FrameHeader) error }
func AcquireFrame ¶
type FrameFlags ¶
type FrameFlags int8
const ( FlagAck FrameFlags = 0x1 FlagEndStream FrameFlags = 0x1 FlagEndHeaders FrameFlags = 0x4 FlagPadded FrameFlags = 0x8 FlagPriority FrameFlags = 0x20 )
Frame Flag (described along the frame types) More flags have been ignored due to redundancy.
func (FrameFlags) Add ¶
func (flags FrameFlags) Add(f FrameFlags) FrameFlags
Add adds a flag to frame flags.
func (FrameFlags) Del ¶
func (flags FrameFlags) Del(f FrameFlags) FrameFlags
Del deletes f from frame flags.
func (FrameFlags) Has ¶
func (flags FrameFlags) Has(f FrameFlags) bool
Has returns if `f` is in the frame flags or not.
type FrameHeader ¶
type FrameHeader struct {
// contains filtered or unexported fields
}
FrameHeader is frame representation of HTTP2 protocol
Use AcquireFrameHeader instead of creating FrameHeader every time if you are going to use FrameHeader as your own and ReleaseFrameHeader to delete the FrameHeader
FrameHeader instance MUST NOT be used from different goroutines.
https://tools.ietf.org/html/rfc7540#section-4.1
func AcquireFrameHeader ¶
func AcquireFrameHeader() *FrameHeader
AcquireFrameHeader gets a FrameHeader from pool.
func ReadFrameFrom ¶
func ReadFrameFrom(br *bufio.Reader) (*FrameHeader, error)
func ReadFrameFromWithSize ¶
func ReadFrameFromWithSize(br *bufio.Reader, max uint32) (*FrameHeader, error)
func (*FrameHeader) Body ¶
func (f *FrameHeader) Body() Frame
func (*FrameHeader) Flags ¶
func (f *FrameHeader) Flags() FrameFlags
func (*FrameHeader) MaxLen ¶
func (f *FrameHeader) MaxLen() uint32
MaxLen returns max negotiated payload length.
func (*FrameHeader) ReadFrom ¶
func (f *FrameHeader) ReadFrom(br *bufio.Reader) (int64, error)
ReadFrom reads frame from Reader.
This function returns read bytes and/or error.
Unlike io.ReaderFrom this method does not read until io.EOF.
func (*FrameHeader) SetBody ¶
func (f *FrameHeader) SetBody(fr Frame)
func (*FrameHeader) SetFlags ¶
func (f *FrameHeader) SetFlags(flags FrameFlags)
func (*FrameHeader) SetStream ¶
func (f *FrameHeader) SetStream(stream uint32)
SetStream sets the stream id on the current frame.
This function DOESN'T delete the reserved bit (first bit) in order to support personalized implementations of the protocol.
func (*FrameHeader) Stream ¶
func (f *FrameHeader) Stream() uint32
Stream returns the stream id of the current frame.
func (*FrameHeader) Type ¶
func (f *FrameHeader) Type() FrameType
Type returns the frame type (https://httpwg.org/specs/rfc7540.html#Frame_types)
type FrameType ¶
type FrameType int8
const FrameContinuation FrameType = 0x9
const FrameData FrameType = 0x0
const FrameGoAway FrameType = 0x7
const FrameHeaders FrameType = 0x1
const FramePing FrameType = 0x6
const FramePriority FrameType = 0x2
const FramePushPromise FrameType = 0x5
const FrameResetStream FrameType = 0x3
const FrameSettings FrameType = 0x4
const FrameWindowUpdate FrameType = 0x8
type FrameWithHeaders ¶
type FrameWithHeaders interface {
Headers() []byte
}
type GoAway ¶
type GoAway struct {
// contains filtered or unexported fields
}
GoAway https://tools.ietf.org/html/rfc7540#section-6.8
func (*GoAway) Deserialize ¶
func (ga *GoAway) Deserialize(fr *FrameHeader) (err error)
func (*GoAway) Serialize ¶
func (ga *GoAway) Serialize(fr *FrameHeader)
type HPACK ¶
type HPACK struct { // DisableCompression disables compression for literal header fields. DisableCompression bool // DisableDynamicTable disables the usage of the dynamic table for // the HPACK structure. If this option is true the HPACK won't add any // field to the dynamic table unless it was sent by the peer. // // This field was implemented because in many ways the server could modify // the fields established by the client losing performance calculated by client. DisableDynamicTable bool // contains filtered or unexported fields }
HPACK represents header compression methods to encode and decode header fields in HTTP/2.
HPACK is equivalent to an HTTP/1 header.
Use AcquireHPACK to acquire new HPACK structure.
func (*HPACK) AppendHeader ¶
func (hp *HPACK) AppendHeader(dst []byte, hf *HeaderField, store bool) []byte
AppendHeader appends the content of an encoded HeaderField to dst.
func (*HPACK) AppendHeaderField ¶
func (hp *HPACK) AppendHeaderField(h *Headers, hf *HeaderField, store bool)
TODO: Change naming.
func (*HPACK) DynamicSize ¶
DynamicSize returns the size of the dynamic table.
func (*HPACK) Next ¶
func (hp *HPACK) Next(hf *HeaderField, b []byte) ([]byte, error)
Next reads and process the contents of `b`. If `b` contains a valid HTTP/2 header the content will be parsed into `hf`.
This function returns the next byte slice that should be read. `b` must be a valid payload coming from a Header frame.
func (*HPACK) Reset ¶
func (hp *HPACK) Reset()
Reset deletes and releases all dynamic header fields.
func (*HPACK) SetMaxTableSize ¶
SetMaxTableSize sets the maximum dynamic table size.
type HeaderField ¶
type HeaderField struct {
// contains filtered or unexported fields
}
HeaderField represents a field in HPACK tables.
Use AcquireHeaderField to acquire HeaderField.
func AcquireHeaderField ¶
func AcquireHeaderField() *HeaderField
AcquireHeaderField gets HeaderField from the pool.
func (*HeaderField) AppendBytes ¶
func (hf *HeaderField) AppendBytes(dst []byte) []byte
AppendBytes appends header representation of hf to dst and returns the new dst.
func (*HeaderField) CopyTo ¶
func (hf *HeaderField) CopyTo(other *HeaderField)
CopyTo copies the HeaderField to `other`.
func (*HeaderField) Empty ¶
func (hf *HeaderField) Empty() bool
Empty returns true if `hf` doesn't contain any key nor value.
func (*HeaderField) IsPseudo ¶
func (hf *HeaderField) IsPseudo() bool
IsPseudo returns true if field is pseudo header.
func (*HeaderField) IsSensible ¶
func (hf *HeaderField) IsSensible() bool
IsSensible returns if header field have been marked as sensible.
func (*HeaderField) KeyBytes ¶
func (hf *HeaderField) KeyBytes() []byte
KeyBytes returns the key bytes of the field.
func (*HeaderField) Set ¶
func (hf *HeaderField) Set(k, v string)
func (*HeaderField) SetBytes ¶
func (hf *HeaderField) SetBytes(k, v []byte)
func (*HeaderField) SetKey ¶
func (hf *HeaderField) SetKey(key string)
SetKey sets key to the field.
func (*HeaderField) SetKeyBytes ¶
func (hf *HeaderField) SetKeyBytes(key []byte)
SetKeyBytes sets key to the field.
func (*HeaderField) SetValue ¶
func (hf *HeaderField) SetValue(value string)
SetValue sets value to the field.
func (*HeaderField) SetValueBytes ¶
func (hf *HeaderField) SetValueBytes(value []byte)
SetValueBytes sets value to the field.
func (*HeaderField) Size ¶
func (hf *HeaderField) Size() uint32
Size returns the header field size as RFC specifies.
func (*HeaderField) String ¶
func (hf *HeaderField) String() string
String returns a string representation of the header field.
func (*HeaderField) Value ¶
func (hf *HeaderField) Value() string
Value returns the value of the field.
func (*HeaderField) ValueBytes ¶
func (hf *HeaderField) ValueBytes() []byte
ValueBytes returns the value bytes of the field.
type Headers ¶
type Headers struct {
// contains filtered or unexported fields
}
Headers defines a FrameHeaders
https://tools.ietf.org/html/rfc7540#section-6.2
func (*Headers) AppendHeaderField ¶
func (h *Headers) AppendHeaderField(hp *HPACK, hf *HeaderField, store bool)
func (*Headers) AppendRawHeaders ¶
AppendRawHeaders appends b to the raw headers.
func (*Headers) Deserialize ¶
func (h *Headers) Deserialize(frh *FrameHeader) error
func (*Headers) EndHeaders ¶
func (*Headers) Serialize ¶
func (h *Headers) Serialize(frh *FrameHeader)
func (*Headers) SetEndHeaders ¶
func (*Headers) SetEndStream ¶
func (*Headers) SetHeaders ¶
func (*Headers) SetPadding ¶
type Ping ¶
type Ping struct {
// contains filtered or unexported fields
}
Ping https://tools.ietf.org/html/rfc7540#section-6.7
func (*Ping) DataAsTime ¶
func (*Ping) Deserialize ¶
func (p *Ping) Deserialize(frh *FrameHeader) error
func (*Ping) Serialize ¶
func (p *Ping) Serialize(fr *FrameHeader)
func (*Ping) SetCurrentTime ¶
func (p *Ping) SetCurrentTime()
type Priority ¶
type Priority struct {
// contains filtered or unexported fields
}
Priority represents the Priority frame.
https://tools.ietf.org/html/rfc7540#section-6.3
func (*Priority) Deserialize ¶
func (pry *Priority) Deserialize(fr *FrameHeader) (err error)
func (*Priority) Serialize ¶
func (pry *Priority) Serialize(fr *FrameHeader)
type PushPromise ¶
type PushPromise struct {
// contains filtered or unexported fields
}
PushPromise https://tools.ietf.org/html/rfc7540#section-6.6
func (*PushPromise) Deserialize ¶
func (pp *PushPromise) Deserialize(fr *FrameHeader) error
func (*PushPromise) Reset ¶
func (pp *PushPromise) Reset()
func (*PushPromise) Serialize ¶
func (pp *PushPromise) Serialize(fr *FrameHeader)
func (*PushPromise) SetHeader ¶
func (pp *PushPromise) SetHeader(h []byte)
func (*PushPromise) Type ¶
func (pp *PushPromise) Type() FrameType
type RstStream ¶
type RstStream struct {
// contains filtered or unexported fields
}
RstStream https://tools.ietf.org/html/rfc7540#section-6.4
func (*RstStream) Deserialize ¶
func (rst *RstStream) Deserialize(fr *FrameHeader) error
func (*RstStream) Serialize ¶
func (rst *RstStream) Serialize(fr *FrameHeader)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server defines an HTTP/2 entity that can handle HTTP/2 connections.
func ConfigureServer ¶
func ConfigureServer(s *fasthttp.Server, cnf ServerConfig) *Server
ConfigureServer configures the fasthttp server to handle HTTP/2 connections. The HTTP/2 connection can be only established if the fasthttp server is using TLS.
Future implementations may support HTTP/2 through plain TCP.
This package currently supports the following fasthttp.Server settings:
- Handler: Obviously, the handler is taken from the Server.
- ReadTimeout: Will cancel a stream if the client takes more than ReadTimeout to send a request. This option NEVER closes the connection.
- IdleTimeout: Will close the connection if the client doesn't send a request within the IdleTimeout. This option ignores any PING/PONG mechanism. To disable the option you can set it to zero. No value is taken by default, which means that by default ALL connections are open until either endpoint closes the connection.
func ConfigureServerAndConfig ¶
ConfigureServerAndConfig configures the fasthttp server to handle HTTP/2 connections and your own tlsConfig file. If you are NOT using your own tls config, you may want to use ConfigureServer.
type ServerConfig ¶
type ServerConfig struct { // PingInterval is the interval at which the server will send a // ping message to a client. // // To disable pings set the PingInterval to a negative value. PingInterval time.Duration // ... MaxConcurrentStreams int // Debug is a flag that will allow the library to print debugging information. Debug bool }
ServerConfig ...
type Settings ¶
type Settings struct {
// contains filtered or unexported fields
}
Settings is the options to establish between endpoints when starting the connection.
These options have been humanized.
func (*Settings) Deserialize ¶
func (st *Settings) Deserialize(fr *FrameHeader) error
func (*Settings) Encode ¶
func (st *Settings) Encode()
Encode encodes settings to be sent through the wire.
func (*Settings) HeaderTableSize ¶
HeaderTableSize returns the maximum size of the header compression table used to decode header blocks.
Default value is 4096.
func (*Settings) MaxConcurrentStreams ¶
MaxConcurrentStreams returns the maximum number of concurrent Streams that the sender will allow.
Default value is 100. This value does not have max limit.
func (*Settings) MaxFrameSize ¶
MaxFrameSize returns the size of the largest frame Payload that the sender is willing to receive.
Default value is 1 << 14 Maximum value is 1 << 24 - 1.
func (*Settings) MaxHeaderListSize ¶
MaxHeaderListSize returns maximum size of header list uncompressed.
If this value is 0 indicates that there are no limit.
func (*Settings) MaxWindowSize ¶
MaxWindowSize returns the sender's initial window size for Stream-level flow control.
Default value is 1 << 16 - 1 Maximum value is 1 << 31 - 1.
func (*Settings) Serialize ¶
func (st *Settings) Serialize(fr *FrameHeader)
func (*Settings) SetHeaderTableSize ¶
SetHeaderTableSize sets the maximum size of the header compression table used to decode header blocks.
Default value is 4096.
func (*Settings) SetMaxConcurrentStreams ¶
SetMaxConcurrentStreams sets the maximum number of concurrent Streams that the sender will allow.
Default value is 100. This value does not have max limit.
func (*Settings) SetMaxFrameSize ¶
SetMaxFrameSize sets the size of the largest frame Payload that the sender is willing to receive.
Default value is 1 << 14 Maximum value is 1 << 24 - 1.
func (*Settings) SetMaxHeaderListSize ¶
SetMaxHeaderListSize sets maximum size of header list uncompressed.
If this value is 0 indicates that there are no limit.
func (*Settings) SetMaxWindowSize ¶
SetMaxWindowSize sets the sender's initial window size for Stream-level flow control.
Default value is 1 << 16 - 1 Maximum value is 1 << 31 - 1.
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
func (*Stream) Ctx ¶
func (s *Stream) Ctx() *fasthttp.RequestCtx
func (*Stream) IncrWindow ¶
func (*Stream) SetData ¶
func (s *Stream) SetData(ctx *fasthttp.RequestCtx)
func (*Stream) SetState ¶
func (s *Stream) SetState(state StreamState)
func (*Stream) State ¶
func (s *Stream) State() StreamState
type StreamState ¶
type StreamState int8
const ( StreamStateIdle StreamState = iota StreamStateReserved StreamStateOpen StreamStateHalfClosed StreamStateClosed )
func (StreamState) String ¶
func (ss StreamState) String() string
type WindowUpdate ¶
type WindowUpdate struct {
// contains filtered or unexported fields
}
WindowUpdate https://tools.ietf.org/html/rfc7540#section-6.9
func (*WindowUpdate) CopyTo ¶
func (wu *WindowUpdate) CopyTo(w *WindowUpdate)
func (*WindowUpdate) Deserialize ¶
func (wu *WindowUpdate) Deserialize(fr *FrameHeader) error
func (*WindowUpdate) Increment ¶
func (wu *WindowUpdate) Increment() int
func (*WindowUpdate) Reset ¶
func (wu *WindowUpdate) Reset()
func (*WindowUpdate) Serialize ¶
func (wu *WindowUpdate) Serialize(fr *FrameHeader)
func (*WindowUpdate) SetIncrement ¶
func (wu *WindowUpdate) SetIncrement(increment int)
func (*WindowUpdate) Type ¶
func (wu *WindowUpdate) Type() FrameType
type WriteError ¶
type WriteError struct {
// contains filtered or unexported fields
}
func (WriteError) As ¶
func (we WriteError) As(target interface{}) bool
func (WriteError) Error ¶
func (we WriteError) Error() string
func (WriteError) Is ¶
func (we WriteError) Is(target error) bool
func (WriteError) Unwrap ¶
func (we WriteError) Unwrap() error