Versions in this module Expand all Collapse all v0 v0.2.4 Apr 29, 2021 Changes in this version + const MaxControlFramePayloadSize + const MaxHeaderSize + var ErrHandshakeBadConnection = RejectConnectionError(RejectionStatus(http.StatusBadRequest), ...) + var ErrHandshakeBadHost = RejectConnectionError(RejectionStatus(http.StatusBadRequest), ...) + var ErrHandshakeBadMethod = RejectConnectionError(RejectionStatus(http.StatusMethodNotAllowed), ...) + var ErrHandshakeBadProtocol = RejectConnectionError(RejectionStatus(http.StatusHTTPVersionNotSupported), ...) + var ErrHandshakeBadSecAccept = RejectConnectionError(RejectionStatus(http.StatusBadRequest), ...) + var ErrHandshakeBadSecKey = RejectConnectionError(RejectionStatus(http.StatusBadRequest), ...) + var ErrHandshakeBadSecVersion = RejectConnectionError(RejectionStatus(http.StatusBadRequest), ...) + var ErrHandshakeBadUpgrade = RejectConnectionError(RejectionStatus(http.StatusBadRequest), ...) + var ErrHandshakeUpgradeRequired = RejectConnectionError(RejectionStatus(http.StatusUpgradeRequired), ...) + var ErrHeaderLengthMSB = fmt.Errorf("header error: the most significant bit must be 0") + var ErrHeaderLengthUnexpected = fmt.Errorf("header error: unexpected payload length bits") + var ErrHeaderNotReady = fmt.Errorf("header error: not enough") + var ErrMalformedRequest = RejectConnectionError(RejectionStatus(http.StatusBadRequest), ...) + var ErrProtocolInvalidUTF8 = ProtocolError("invalid utf8 sequence in close reason") + var ErrProtocolStatusCodeApplicationLevel = ProtocolError("status code is only application level") + var ErrProtocolStatusCodeNoMeaning = ProtocolError("status code has no meaning yet") + var ErrProtocolStatusCodeNotInUse = ProtocolError("status code is not in use") + var ErrProtocolStatusCodeUnknown = ProtocolError("status code is not defined in spec") + var StatusRangeApplication = StatusCodeRange + var StatusRangeNotInUse = StatusCodeRange + var StatusRangePrivate = StatusCodeRange + var StatusRangeProtocol = StatusCodeRange + func Cipher(payload []byte, mask [4]byte, offset int) + func FrameToBytes(f *Frame) (ret []byte, err error) + func NewCloseFrameBody(code StatusCode, reason string) []byte + func PutCloseFrameBody(p []byte, code StatusCode, reason string) + func RejectConnectionError(options ...RejectOption) error + func WriteHeader(h *Header) ([]byte, error) + type Frame struct + Header Header + Payload []byte + func NewBinaryFrame(p []byte) *Frame + func NewCloseFrame(p []byte) *Frame + func NewFrame(op OpCode, fin bool, p []byte) *Frame + func NewPingFrame(p []byte) *Frame + func NewPongFrame(p []byte) *Frame + func NewTextFrame(p []byte) *Frame + type Handshake struct + Extensions []httphead.Option + Protocol string + type HandshakeHeader interface + type HandshakeHeaderBytes []byte + func (b HandshakeHeaderBytes) WriteTo(w io.Writer) (int64, error) + type HandshakeHeaderFunc func(io.Writer) (int64, error) + func (f HandshakeHeaderFunc) WriteTo(w io.Writer) (int64, error) + type HandshakeHeaderHTTP http.Header + func (h HandshakeHeaderHTTP) WriteTo(w io.Writer) (int64, error) + type HandshakeHeaderString string + func (s HandshakeHeaderString) WriteTo(w io.Writer) (int64, error) + type Header struct + Fin bool + Length int64 + Mask [4]byte + Masked bool + OpCode OpCode + Rsv byte + func VirtualReadHeader(bts []byte, in *ringbuffer.RingBuffer) (h Header, err error) + func (h Header) Rsv1() bool + func (h Header) Rsv2() bool + func (h Header) Rsv3() bool + type MessageType int + const MessageBinary + const MessageText + type OpCode byte + const OpBinary + const OpClose + const OpContinuation + const OpPing + const OpPong + const OpText + func (c OpCode) IsControl() bool + func (c OpCode) IsData() bool + func (c OpCode) IsReserved() bool + type ProtocolError string + func (p ProtocolError) Error() string + type RejectOption func(*rejectConnectionError) + func RejectionHeader(h HandshakeHeader) RejectOption + func RejectionReason(reason string) RejectOption + func RejectionStatus(code int) RejectOption + type StatusCode uint16 + const StatusAbnormalClosure + const StatusGoingAway + const StatusInternalServerError + const StatusInvalidFramePayloadData + const StatusMandatoryExt + const StatusMessageTooBig + const StatusNoMeaningYet + const StatusNoStatusRcvd + const StatusNormalClosure + const StatusPolicyViolation + const StatusProtocolError + const StatusTLSHandshake + const StatusUnsupportedData + func ParseCloseFrameData(payload []byte) (code StatusCode, reason string) + func (s StatusCode) Empty() bool + func (s StatusCode) In(r StatusCodeRange) bool + func (s StatusCode) IsApplicationSpec() bool + func (s StatusCode) IsNotUsed() bool + func (s StatusCode) IsPrivateSpec() bool + func (s StatusCode) IsProtocolDefined() bool + func (s StatusCode) IsProtocolReserved() bool + func (s StatusCode) IsProtocolSpec() bool + type StatusCodeRange struct + Max StatusCode + Min StatusCode + type Upgrader struct + Extension func(httphead.Option) bool + ExtensionCustom func(*connection.Connection, []byte, []httphead.Option) ([]httphead.Option, bool) + Header HandshakeHeader + OnBeforeUpgrade func(c *connection.Connection) (header HandshakeHeader, err error) + OnHeader func(c *connection.Connection, key, value []byte) error + OnHost func(c *connection.Connection, host []byte) error + OnRequest func(c *connection.Connection, uri []byte) error + Protocol func([]byte) bool + ProtocolCustom func(*connection.Connection, []byte) (string, bool) + func (u *Upgrader) Upgrade(c *connection.Connection, in *ringbuffer.RingBuffer) (out []byte, hs Handshake, err error)