h2c

package
v0.0.0-...-2d9777f Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStreamCancelled = wrapErr{"request cancelled", nil}
)

Functions

func GetMaxFrameSize

func GetMaxFrameSize(fs uint32) uint32

Types

type ClientSettings

type ClientSettings struct {
	HeaderTableSize        uint32
	EnablePush             uint32
	MaxConcurrentStreams   uint32
	InitialWindowSize      uint32
	MaxReadFrameSize       uint32
	MaxWriteFrameSize      uint32
	MaxReadHeaderListSize  uint32
	MaxWriteHeaderListSize uint32
	// contains filtered or unexported fields
}

ClientSettings is a set of http2 settings used for *clients*

func NewSettings

func NewSettings() *ClientSettings

NewSettings creates a settings instance with default values

func (*ClientSettings) On

func (s *ClientSettings) On(id http2.SettingID, do func(value uint32))

On registers callback on server pushed settings to client

func (*ClientSettings) UpdateFrom

func (s *ClientSettings) UpdateFrom(frame *http2.SettingsFrame)

type Connection

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

Connection 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.

func NewConn

func NewConn(c net.Conn) *Connection

func (*Connection) Close

func (c *Connection) Close() error

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

func (*Connection) Handshake

func (c *Connection) Handshake() error

Handshake performs PRI handshake on the underlying net.Conn

func (*Connection) Ping

func (c *Connection) 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 (*Connection) Read

func (c *Connection) Read([]byte) (int, error)

func (*Connection) Stream

func (c *Connection) Stream() (net.Conn, error)

func (*Connection) Upgrade

func (c *Connection) 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 (*Connection) Write

func (c *Connection) Write([]byte) (n int, err error)

type Stream

type Stream struct {
	*Connection
	// contains filtered or unexported fields
}

func (*Stream) Close

func (s *Stream) Close() error

Close implements net.Conn.

func (*Stream) Flush

func (s *Stream) Flush() error

func (*Stream) ID

func (s *Stream) ID() uint32

func (*Stream) Read

func (s *Stream) Read(b []byte) (n int, err error)

Read implements net.Conn.

func (*Stream) Write

func (s *Stream) Write(b []byte) (n int, err error)

Write implements net.Conn.

func (*Stream) WriteHeaders

func (s *Stream) WriteHeaders(ctx context.Context, enumHeaders func(func(k, v string)), last bool) error

Jump to

Keyboard shortcuts

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