Documentation
¶
Index ¶
- Constants
- Variables
- type BufReader
- func (b *BufReader) Close() error
- func (b *BufReader) LocalAddr() net.Addr
- func (b *BufReader) Read(p []byte) (n int, err error)
- func (b *BufReader) RemoteAddr() net.Addr
- func (b *BufReader) SetDeadline(t time.Time) error
- func (b *BufReader) SetReadDeadline(t time.Time) error
- func (b *BufReader) SetWriteDeadline(t time.Time) error
- func (b *BufReader) Write(p []byte) (n int, err error)
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) RecvFrame(ctx context.Context) (Frame, error)
- func (c *Conn) RecvRequestBody(ctx context.Context, request *Request) error
- func (c *Conn) RecvRequestHeaders(ctx context.Context) (*Request, error)
- func (c *Conn) SendData(streamId uint32, flags FrameFlags, body []byte) error
- func (c *Conn) SendHeaders(streamId uint32, flags FrameFlags, headers []hpack.HeaderField) error
- func (c *Conn) SendTrailerFrame(streamId uint32, headers []hpack.HeaderField) error
- func (c *Conn) ServerHandshake(ctx context.Context) (*Request, error)
- type DataFrame
- type ErrProtocolError
- type ErrWrongHTTPRequest
- type ErrorCode
- type Frame
- type FrameFlags
- type FrameHdr
- type FrameType
- type GoawayFrame
- type Handler
- type HeadersFrame
- type PingFrame
- type Request
- type Response
- type RstStreamFrame
- type Server
- func (s *Server) Listen(l net.Listener)
- func (s *Server) ListenTCP(addr string) error
- func (s *Server) ListenTLS(l net.Listener, certs ...tls.Certificate)
- func (s *Server) Serve(ctx context.Context) error
- func (s *Server) SetGRPPCHandler(desc grpc.ServiceDesc, h Handler)
- func (s *Server) SetGRPPCStreamHandler(desc grpc.ServiceDesc, h StreamHandler)
- func (s *Server) SetHTTPHandler(h Handler)
- type Settings
- type SettingsFrame
- type SettingsFrameParam
- type SettingsType
- type StreamHandler
- type WindowUpdateFrame
Constants ¶
View Source
const ( ErrorCodeNoError = ErrorCode(0x0) ErrorCodeProtocolError = ErrorCode(0x1) ErrorCodeInternalError = ErrorCode(0x2) ErrorCodeFlowControlError = ErrorCode(0x3) ErrorCodeSettingsTimeout = ErrorCode(0x4) ErrorCodeStreamClosed = ErrorCode(0x5) ErrorCodeFrameSizeError = ErrorCode(0x6) ErrorCodeRefusedStream = ErrorCode(0x7) ErrorCodeCancel = ErrorCode(0x8) ErrorCodeCompressionError = ErrorCode(0x9) ErrorCodeConnectError = ErrorCode(0xa) ErrorCodeEnhanceYourCalm = ErrorCode(0xb) ErrorCodeInadequateSecurity = ErrorCode(0xc) ErrorCodeHTTP11Required = ErrorCode(0xd) )
View Source
const ( FlagAck = FrameFlags(0x1) FlagEndStream = FrameFlags(0x1) FlagEndHeaders = FrameFlags(0x4) FlagPadded = FrameFlags(0x8) FlagPriority = FrameFlags(0x20) )
View Source
const ( FrameTypeData = FrameType(0) FrameTypeHeaders = FrameType(1) FrameTypePriority = FrameType(2) FrameTypeRstStream = FrameType(3) FrameTypeSettings = FrameType(4) FrameTypePushPromise = FrameType(5) FrameTypePing = FrameType(6) FrameTypeGoaway = FrameType(7) FrameTypeWindowUpdate = FrameType(8) FrameTypeContinuation = FrameType(9) )
View Source
const ( SettingsHeaderTableSize = SettingsType(0x1) SettingsEnablePush = SettingsType(0x2) SettingsMaxConcurrentStreams = SettingsType(0x3) SettingsInitialWindowSize = SettingsType(0x4) SettingsMaxFrameSize = SettingsType(0x5) SettingsMaxHeaderListSize = SettingsType(0x6) )
View Source
const (
RecvBufferSize = 16 * 1024
)
Variables ¶
Functions ¶
This section is empty.
Types ¶
type BufReader ¶
type BufReader struct {
// contains filtered or unexported fields
}
BufReader is a wrapper around net.Conn which for reading first reads from the internal buffer (prepend), and then from the connection (src)
func (*BufReader) RemoteAddr ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn implements HTTP/2 connection
func (*Conn) RecvRequestBody ¶
RecvRequestBody receives only DATA frames until gets FlagEndStream
func (*Conn) RecvRequestHeaders ¶
RecvRequestHeaders receives only HEADER frames until gets FlagEndHeaders
func (*Conn) SendData ¶
func (c *Conn) SendData(streamId uint32, flags FrameFlags, body []byte) error
func (*Conn) SendHeaders ¶
func (c *Conn) SendHeaders(streamId uint32, flags FrameFlags, headers []hpack.HeaderField) error
func (*Conn) SendTrailerFrame ¶
func (c *Conn) SendTrailerFrame(streamId uint32, headers []hpack.HeaderField) error
type ErrProtocolError ¶
type ErrProtocolError struct {
Descr string
}
func (*ErrProtocolError) Error ¶
func (e *ErrProtocolError) Error() string
func (*ErrProtocolError) Http2Error ¶
func (e *ErrProtocolError) Http2Error() string
type ErrWrongHTTPRequest ¶
type ErrWrongHTTPRequest struct {
Cause error
}
func NewErrWrongHTTPRequest ¶
func NewErrWrongHTTPRequest(cause error) *ErrWrongHTTPRequest
func (*ErrWrongHTTPRequest) Error ¶
func (e *ErrWrongHTTPRequest) Error() string
type FrameFlags ¶
type FrameFlags uint8
func (FrameFlags) String ¶
func (f FrameFlags) String() string
type FrameHdr ¶
type FrameHdr struct { Length uint32 Type FrameType Flags FrameFlags StreamId uint32 }
type GoawayFrame ¶
func (*GoawayFrame) ReadPayload ¶
func (f *GoawayFrame) ReadPayload(frameHdr *FrameHdr, payload []byte) error
func (*GoawayFrame) WritePayload ¶
func (f *GoawayFrame) WritePayload(dst []byte) []byte
type HeadersFrame ¶
type HeadersFrame struct { FrameHdr Exclusive bool // A single bit flag indicating that the stream dependency is exclusive. This field is only present if the PRIORITY flag is set. StreamIdDepend uint32 // This field is only present if the PRIORITY flag is set. Weight uint8 // This field is only present if the PRIORITY flag is set. HeaderBlockFragment []hpack.HeaderField // contains filtered or unexported fields }
func (*HeadersFrame) ReadPayload ¶
func (f *HeadersFrame) ReadPayload(frameHdr *FrameHdr, payload []byte) error
func (*HeadersFrame) WritePayload ¶
type Request ¶
type Request struct { Method string URI string HTTPVersion string StreamId uint32 Headers map[string]string Body []byte // contains filtered or unexported fields }
func NewHTTPRequest ¶
type RstStreamFrame ¶
func (*RstStreamFrame) ReadPayload ¶
func (f *RstStreamFrame) ReadPayload(frameHdr *FrameHdr, payload []byte) error
func (*RstStreamFrame) WritePayload ¶
func (f *RstStreamFrame) WritePayload(dst []byte) []byte
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) Listen ¶
Listen adds listener for future Serve()
You can initialize a listener:
l, _ := net.Listen("tcp", ":80") NewServer().Listen(l)
func (*Server) ListenTLS ¶
func (s *Server) ListenTLS(l net.Listener, certs ...tls.Certificate)
ListenTLS wraps listener to TLS with certs
You can load a cert from pair:
l, _ := net.Listen("tcp", ":443") cert, _ := tls.X509KeyPair([]byte(certPEMBlock), []byte(keyPEMBlock)) NewServer().ListenTLS(l, cert)
func (*Server) SetGRPPCHandler ¶
func (s *Server) SetGRPPCHandler(desc grpc.ServiceDesc, h Handler)
func (*Server) SetGRPPCStreamHandler ¶
func (s *Server) SetGRPPCStreamHandler(desc grpc.ServiceDesc, h StreamHandler)
func (*Server) SetHTTPHandler ¶
type Settings ¶
type Settings struct { HeaderTableSize uint32 EnablePush bool MaxConcurrentStreams uint32 InitialWindowSize uint32 MaxFrameSize uint32 MaxHeaderListSize uint32 }
func GetDefaultSettings ¶
func GetDefaultSettings() Settings
func (*Settings) ToSettingsFrame ¶
func (s *Settings) ToSettingsFrame() *SettingsFrame
func (*Settings) UpdateFromSettingsFrame ¶
func (s *Settings) UpdateFromSettingsFrame(frame *SettingsFrame)
type SettingsFrame ¶
type SettingsFrame struct { FrameHdr Params []SettingsFrameParam }
func (*SettingsFrame) ReadPayload ¶
func (f *SettingsFrame) ReadPayload(frameHdr *FrameHdr, payload []byte) error
func (*SettingsFrame) WritePayload ¶
func (f *SettingsFrame) WritePayload(dst []byte) []byte
type SettingsFrameParam ¶
type SettingsFrameParam struct { Id SettingsType Value uint32 }
type SettingsType ¶
type SettingsType uint8
func (SettingsType) String ¶
func (s SettingsType) String() string
type StreamHandler ¶
type WindowUpdateFrame ¶
func (*WindowUpdateFrame) ReadPayload ¶
func (f *WindowUpdateFrame) ReadPayload(frameHdr *FrameHdr, payload []byte) error
func (*WindowUpdateFrame) WritePayload ¶
func (f *WindowUpdateFrame) WritePayload(dst []byte) []byte
Click to show internal directories.
Click to hide internal directories.