controller

package
v0.0.0-...-faeea24 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMultipleGoAway = errors.New("connection already seen GOAWAY")
	ErrReasonNil      = errors.New("connection closed without reason, this is unexpected")
)

Functions

This section is empty.

Types

type Controller

type Controller struct {
	net.Conn
	// contains filtered or unexported fields
}

Controller holds the same purpose as golang.org/x/net/http.ClientConn, yet it couples with net/http.Transport deeply, so we are re-implementing it.

Controller implements *connection level* flow control, ping/pong, settings for both sides, and maintains connection state

func NewController

func NewController(c net.Conn) *Controller

func (*Controller) ConfigureReadSetting

func (s *Controller) ConfigureReadSetting(id http2.SettingID, val uint32) error

func (*Controller) EncodeHeaders

func (h *Controller) EncodeHeaders(enumHeaders func(func(k, v string)), do func(data []byte) error) error

EncodeHeaders encodes HEADERS frame BlockFragment

func (*Controller) GoAway

func (c *Controller) GoAway(lastStreamID uint32, code http2.ErrCode) (err error)

GoAway actively sends GOAWAY to remote peer. It must not be called by Controller after handshake, but should be called by [h2c.Connection] instead

func (*Controller) GoAwayDebug

func (c *Controller) GoAwayDebug(lastStreamID uint32, code http2.ErrCode, debug []byte) (err error)

GoAwayDebug actively sends GOAWAY to remote peer with debug info. It must not be called by Controller after handshake, but should be called by [h2c.Connection] instead

func (*Controller) Handshake

func (c *Controller) Handshake() error

Handshake performs PRI handshake on the underlying net.Conn

func (*Controller) OnAfterHandshake

func (c *Controller) OnAfterHandshake(cb func())

func (*Controller) OnData

func (c *Controller) OnData(cb func(*http2.DataFrame))

func (*Controller) OnHeader

func (c *Controller) OnHeader(cb func(*http2.MetaHeadersFrame))

func (*Controller) OnRemoteGoAway

func (c *Controller) OnRemoteGoAway(cb func(lastStreamID uint32, errCode http2.ErrCode))

func (*Controller) OnSettings

func (c *Controller) OnSettings(cb func(*http2.SettingsFrame))

func (*Controller) OnStreamReset

func (c *Controller) OnStreamReset(cb func(*http2.RSTStreamFrame))

func (*Controller) OnWindowUpdate

func (c *Controller) OnWindowUpdate(cb func(*http2.WindowUpdateFrame))

func (*Controller) Ping

func (p *Controller) Ping() error

Ping could fail due to unstable connection when the server doesn't acknoledge it in 10 seconds, try not make connection state change decisions based on the Ping results. This is mostly used for debugging and keeping connection alive. Ping shouldn't be called rapidly or a large number of channels would be created.

func (*Controller) ReadFrame

func (f *Controller) ReadFrame() (http2.Frame, error)

func (*Controller) UpdatePeerSettings

func (s *Controller) UpdatePeerSettings(sf *http2.SettingsFrame) (func(), error)

func (*Controller) Upgrade

func (c *Controller) Upgrade(host string) error

Upgrade performs HTTP1 Upgrade to h2c on the underlying net.Conn GET / HTTP/1.1 Host: example.com Connection: Upgrade, HTTP2-Settings Upgrade: h2c HTTP2-Settings: <base64url encoding of HTTP/2 SETTINGS payload>

func (*Controller) UsePeerSetting

func (s *Controller) UsePeerSetting(id http2.SettingID) (uint32, func())

func (*Controller) UseSelfSetting

func (s *Controller) UseSelfSetting(id http2.SettingID) (uint32, func())

func (*Controller) Valid

func (c *Controller) Valid() error

Valid returns error if connection is no longer available

func (*Controller) WaitAndClose

func (c *Controller) WaitAndClose() error

Close on *Framer should try to gracefully shutdown the underlying connection asynchronously

func (*Controller) WriteContinuation

func (f *Controller) WriteContinuation(streamID uint32, endHeaders bool, headerBlockFragment []byte) error

func (*Controller) WriteData

func (f *Controller) WriteData(streamID uint32, endStream bool, data []byte) error

func (*Controller) WriteGoAway

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

func (*Controller) WriteHeaders

func (f *Controller) WriteHeaders(p http2.HeadersFrameParam) error

func (*Controller) WritePing

func (f *Controller) WritePing(ack bool, data [8]byte) error

func (*Controller) WriteRSTStream

func (f *Controller) WriteRSTStream(streamID uint32, code http2.ErrCode) error

func (*Controller) WriteSettings

func (f *Controller) WriteSettings(settings ...http2.Setting) error

func (*Controller) WriteSettingsAck

func (f *Controller) WriteSettingsAck() error

func (*Controller) WriteWindowUpdate

func (f *Controller) WriteWindowUpdate(streamID, incr uint32) error

type ReasonGoAway

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

func (*ReasonGoAway) Error

func (r *ReasonGoAway) Error() string

Jump to

Keyboard shortcuts

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