Documentation
¶
Index ¶
Constants ¶
const HTTPVersion = "1.1"
HTTPVersion constant
const UsedWSVersion = 13
UsedWSVersion constant websocket version
const WSSalt = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
WSSalt constant websocket salt
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Header ¶
type Header struct { Name HeaderType Values HeaderValue }
Header represents the data of a HTTP request header
func ReadHeader ¶
ReadHeader tries to parse an HTTP header from a byte array
type HeaderType ¶
type HeaderType uint8
HeaderType represents all 'valid' HTTP request headers
const ( Unknown HeaderType = iota Host Upgrade Connection Origin WSKey WSProtocol WSExtensions WSVersion )
header types
type HeaderValue ¶
type HeaderValue [][]byte
HeaderValue represents a unique or multiple header value(s)
type IncompleteRequest ¶
type IncompleteRequest struct {
MissingField string
}
Request misses fields (request-line or headers)
func (IncompleteRequest) Error ¶
func (err IncompleteRequest) Error() string
type InvalidOriginPolicy ¶
type InvalidOriginPolicy struct { Host string Origin string // contains filtered or unexported fields }
Request has a violated origin policy
func (InvalidOriginPolicy) Error ¶
func (err InvalidOriginPolicy) Error() string
type InvalidRequest ¶
invalid request - multiple-value if only 1 expected
func (InvalidRequest) Error ¶
func (err InvalidRequest) Error() string
type Line ¶
type Line struct {
// contains filtered or unexported fields
}
Line represents the HTTP Request line defined in rfc-2616 : https://tools.ietf.org/html/rfc2616#section-5.1
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request represents an HTTP Upgrade request
func Parse ¶
Parse builds an upgrade HTTP request from a reader (typically bufio.NewRead of the socket)
func (*Request) BuildResponse ¶
BuildResponse builds a response from the request
func (Request) StatusCode ¶
func (r Request) StatusCode() StatusCode
StatusCode returns the status current
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response represents an HTTP Upgrade Response
func (Response) GetProtocol ¶
GetProtocol returns the choosen protocol if set, else nil
func (Response) GetStatusCode ¶
func (r Response) GetStatusCode() StatusCode
GetStatusCode returns the response status code
func (*Response) ProcessKey ¶
ProcessKey processes the accept token according to the rfc from the Sec-WebSocket-Key
func (*Response) SetProtocol ¶
SetProtocol sets the protocols
func (*Response) SetStatusCode ¶
func (r *Response) SetStatusCode(sc StatusCode)
SetStatusCode sets the status code
type StatusCode ¶
type StatusCode uint16
StatusCode maps the status codes (and description)
const ( // SwitchingProtocols - handshake success SwitchingProtocols StatusCode = 101 // BadRequest - missing/malformed headers BadRequest StatusCode = 400 // Forbidden - invalid origin policy, TLS required Forbidden StatusCode = 403 // UpgradeRequired - invalid WS version UpgradeRequired StatusCode = 426 // NotFound - unserved or invalid URI NotFound StatusCode = 404 // Internal - custom error Internal StatusCode = 500 )
func (StatusCode) String ¶
func (sc StatusCode) String() string
String implements the Stringer interface