Versions in this module Expand all Collapse all v0 v0.4.0 Sep 24, 2023 Changes in this version + const DefaultFrameSize + const DefaultMaxResponseTime + const DefaultPingInterval + const EnablePush + const H2Clean + const H2TLSProto + const HeaderTableSize + const MaxConcurrentStreams + const MaxFrameSize + const MaxHeaderListSize + const MaxWindowSize + var ErrCompression = NewGoAwayError(CompressionError, "Compression error") + var ErrDynamicUpdate = errors.New("dynamic update received after the first header block") + var ErrDynamicUpdateMaxTableSize = errors.New("dynamic update is over the max table") + var ErrMissingBytes = NewError(ProtocolError, "missing payload bytes. Need more") + var ErrNotAvailableStreams = errors.New("ran out of available streams") + var ErrPayloadExceeds = NewError(FrameSizeError, "FrameHeader payload exceeds the negotiated maximum size") + var ErrRequestCanceled = errors.New("request timed out") + var ErrServerSupport = errors.New("server doesn't support HTTP/2") + var ErrStreamNotReady = errors.New("stream hasn't been created") + var ErrTimeout = errors.New("server is not replying to pings") + var ErrUnexpectedSize = errors.New("unexpected size") + var ErrUnknownFrameType = NewError(ProtocolError, "unknown frame type") + var StringAuthority = []byte(":authority") + var StringContentLength = []byte("content-length") + var StringContentType = []byte("content-type") + var StringGET = []byte("GET") + var StringGzip = []byte("gzip") + var StringHEAD = []byte("HEAD") + var StringHTTP2 = []byte("HTTP/2") + var StringMethod = []byte(":method") + var StringPOST = []byte("POST") + var StringPath = []byte(":path") + var StringScheme = []byte(":scheme") + var StringServer = []byte("server") + var StringStatus = []byte(":status") + var StringUserAgent = []byte("user-agent") + 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 struct + func (cl *Client) RoundTrip(hc *fasthttp.HostClient, req *fasthttp.Request, res *fasthttp.Response) (retry bool, err error) + type ClientOpts struct + MaxResponseTime time.Duration + OnRTT func(time.Duration) + PingInterval time.Duration + type Conn struct + func NewConn(c net.Conn, opts ConnOpts) *Conn + func (c *Conn) CanOpenStream() bool + func (c *Conn) Cancel(ctx *Ctx) error + func (c *Conn) Close() error + func (c *Conn) Closed() bool + func (c *Conn) Handshake() error + func (c *Conn) LastErr() error + func (c *Conn) SetOnDisconnect(cb func(*Conn)) + func (c *Conn) Write(r *Ctx) + type ConnOpts struct + DisablePingChecking bool + OnDisconnect func(c *Conn) + PingInterval time.Duration + type Continuation struct + 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 struct + Err chan error + Request *fasthttp.Request + Response *fasthttp.Response + type Data struct + 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 struct + Addr string + NetDial fasthttp.DialFunc + PingInterval time.Duration + TLSConfig *tls.Config + func (d *Dialer) Dial(opts ConnOpts) (*Conn, error) + type Error struct + func NewError(e ErrorCode, debug string) Error + func NewGoAwayError(e ErrorCode, debug string) Error + func NewResetStreamError(e ErrorCode, debug string) Error + func (e Error) Code() ErrorCode + func (e Error) Debug() string + func (e Error) Error() string + func (e Error) Is(target error) bool + type ErrorCode uint32 + const CompressionError + const ConnectionError + const EnhanceYourCalm + const FlowControlError + const FrameSizeError + const HTTP11Required + const InadequateSecurity + const InternalError + const NoError + const ProtocolError + const RefusedStreamError + const SettingsTimeoutError + const StreamCanceled + const StreamClosedError + func (e ErrorCode) Error() string + func (e ErrorCode) String() string + type Frame interface + Deserialize func(*FrameHeader) error + Reset func() + Serialize func(*FrameHeader) + Type func() FrameType + func AcquireFrame(ftype FrameType) Frame + type FrameFlags int8 + const FlagAck + const FlagEndHeaders + const FlagEndStream + const FlagPadded + const FlagPriority + func (flags FrameFlags) Add(f FrameFlags) FrameFlags + func (flags FrameFlags) Del(f FrameFlags) FrameFlags + func (flags FrameFlags) Has(f FrameFlags) bool + type FrameHeader struct + func AcquireFrameHeader() *FrameHeader + func ReadFrameFrom(br *bufio.Reader) (*FrameHeader, error) + func ReadFrameFromWithSize(br *bufio.Reader, max uint32) (*FrameHeader, error) + 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 int8 + const FrameContinuation + const FrameData + const FrameGoAway + const FrameHeaders + const FramePing + const FramePriority + const FramePushPromise + const FrameResetStream + const FrameSettings + const FrameWindowUpdate + func (ft FrameType) String() string + type FrameWithHeaders interface + Headers func() []byte + type GoAway struct + 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 struct + DisableCompression bool + DisableDynamicTable bool + func AcquireHPACK() *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 struct + func AcquireHeaderField() *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 struct + 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 struct + 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 struct + 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 struct + func (pp *PushPromise) Deserialize(fr *FrameHeader) error + func (pp *PushPromise) Reset() + func (pp *PushPromise) Serialize(fr *FrameHeader) + func (pp *PushPromise) SetHeader(h []byte) + func (pp *PushPromise) Type() FrameType + func (pp *PushPromise) Write(b []byte) (int, error) + type RstStream struct + 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 struct + func ConfigureServer(s *fasthttp.Server, cnf ServerConfig) *Server + func ConfigureServerAndConfig(s *fasthttp.Server, tlsConfig *tls.Config) *Server + func (s *Server) ServeConn(c net.Conn) error + type ServerConfig struct + Debug bool + MaxConcurrentStreams int + PingInterval time.Duration + type Settings struct + 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 struct + func NewStream(id uint32, win int32) *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 int8 + const StreamStateClosed + const StreamStateHalfClosed + const StreamStateIdle + const StreamStateOpen + const StreamStateReserved + func (ss StreamState) String() string + type Streams []*Stream + func (strms *Streams) Del(id uint32) + func (strms *Streams) Search(id uint32) *Stream + func (strms Streams) GetFirstOf(frameType FrameType) *Stream + type WindowUpdate struct + 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 struct + func (we WriteError) As(target interface{}) bool + func (we WriteError) Error() string + func (we WriteError) Is(target error) bool + func (we WriteError) Unwrap() error