Documentation ¶
Index ¶
- Variables
- type Controller
- func (s *Controller) ConfigureReadSetting(id http2.SettingID, val uint32) error
- func (h *Controller) EncodeHeaders(enumHeaders func(func(k, v string)), do func(data []byte) error) error
- func (c *Controller) GoAway(lastStreamID uint32, code http2.ErrCode) (err error)
- func (c *Controller) GoAwayDebug(lastStreamID uint32, code http2.ErrCode, debug []byte) (err error)
- func (c *Controller) Handshake() error
- func (c *Controller) OnAfterHandshake(cb func())
- func (c *Controller) OnData(cb func(*http2.DataFrame))
- func (c *Controller) OnHeader(cb func(*http2.MetaHeadersFrame))
- func (c *Controller) OnRemoteGoAway(cb func(lastStreamID uint32, errCode http2.ErrCode))
- func (c *Controller) OnSettings(cb func(*http2.SettingsFrame))
- func (c *Controller) OnStreamReset(cb func(*http2.RSTStreamFrame))
- func (c *Controller) OnWindowUpdate(cb func(*http2.WindowUpdateFrame))
- func (p *Controller) Ping() error
- func (f *Controller) ReadFrame() (http2.Frame, error)
- func (s *Controller) UpdatePeerSettings(sf *http2.SettingsFrame) (func(), error)
- func (c *Controller) Upgrade(host string) error
- func (s *Controller) UsePeerSetting(id http2.SettingID) (uint32, func())
- func (s *Controller) UseSelfSetting(id http2.SettingID) (uint32, func())
- func (c *Controller) Valid() error
- func (c *Controller) WaitAndClose() error
- func (f *Controller) WriteContinuation(streamID uint32, endHeaders bool, headerBlockFragment []byte) error
- func (f *Controller) WriteData(streamID uint32, endStream bool, data []byte) error
- func (f *Controller) WriteGoAway(maxStreamID uint32, code http2.ErrCode, debugData []byte) error
- func (f *Controller) WriteHeaders(p http2.HeadersFrameParam) error
- func (f *Controller) WritePing(ack bool, data [8]byte) error
- func (f *Controller) WriteRSTStream(streamID uint32, code http2.ErrCode) error
- func (f *Controller) WriteSettings(settings ...http2.Setting) error
- func (f *Controller) WriteSettingsAck() error
- func (f *Controller) WriteWindowUpdate(streamID, incr uint32) error
- type ReasonGoAway
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 (*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 ¶
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) 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 (*Controller) UseSelfSetting ¶
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 (*Controller) WriteGoAway ¶
func (*Controller) WriteHeaders ¶
func (f *Controller) WriteHeaders(p http2.HeadersFrameParam) error
func (*Controller) WriteRSTStream ¶
func (*Controller) WriteSettings ¶
func (*Controller) WriteSettingsAck ¶
func (f *Controller) WriteSettingsAck() error
func (*Controller) WriteWindowUpdate ¶
type ReasonGoAway ¶
type ReasonGoAway struct {
// contains filtered or unexported fields
}
func (*ReasonGoAway) Error ¶
func (r *ReasonGoAway) Error() string