Documentation
¶
Overview ¶
Package wsmini is the minimal RFC 6455 framing the Sprites exec channel needs, so the module takes no WebSocket dependency. It has a client (Dial) and a server side (Upgrade, for the Sprites fake): binary and text messages, fragmentation, ping/pong, close, masking rules and a message size limit. There is no compression, no extension and no subprotocol.
Index ¶
Constants ¶
const ( OpText = 0x1 OpBinary = 0x2 OpClose = 0x8 OpPing = 0x9 OpPong = 0xA )
Opcodes.
const DefaultMaxMessage = 16 << 20
DefaultMaxMessage bounds one reassembled message.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is one WebSocket connection. ReadMessage must be called from one goroutine at a time; WriteMessage is safe for concurrent use.
func Upgrade ¶
Upgrade is the server side: it checks the upgrade request, hijacks the connection and answers 101. A request that is not a valid upgrade is answered 400 and an error is returned.
func (*Conn) ReadMessage ¶
ReadMessage returns the next text or binary message. Pings are answered and pongs dropped meanwhile. A close frame is answered and returns ErrClosed.
func (*Conn) SetReadDeadline ¶
SetReadDeadline passes through to the connection.
type DialError ¶
type DialError struct{ Err error }
DialError: the connection could not be made, so no request byte was sent.
type DialOptions ¶
type DialOptions struct {
Header http.Header
MaxMessage int
HandshakeTimeout time.Duration
TLS *tls.Config
}
DialOptions: Header is added to the upgrade request; MaxMessage defaults to DefaultMaxMessage; HandshakeTimeout bounds the wait for the upgrade answer (default 30s); TLS is used for https and wss URLs (nil: the system roots).
type HandshakeError ¶
type HandshakeError struct{ Err error }
HandshakeError: the upgrade request was written (the server may have acted on it), and the exchange then failed without an HTTP error status: a timeout, a network error, a bad answer.
func (*HandshakeError) Error ¶
func (e *HandshakeError) Error() string
func (*HandshakeError) Unwrap ¶
func (e *HandshakeError) Unwrap() error
type StatusError ¶
StatusError: the server answered the upgrade request with an HTTP status other than 101.
func (*StatusError) Error ¶
func (e *StatusError) Error() string