http_websocket

WebSocket protocol versions 13 and 8.

Module Contents

Classes

WSCloseCode()
WSMsgType()
WSMessage()
WebSocketError(self,code,message) WebSocket protocol parser error.
WSHandshakeError() WebSocket protocol handshake error.
WSParserState()
WebSocketReader(self,queue,max_msg_size,compress=True)
WebSocketWriter(self,protocol,transport)

Functions

_websocket_mask_python(mask,data) Websocket masking function.
ws_ext_parse(extstr,isserver=False)
ws_ext_gen(compress=15,isserver=False,server_notakeover=False)
class WSCloseCode
class WSMsgType
class WSMessage
json()

Return parsed JSON data.

New in version 0.22.

class WebSocketError(code, message)

WebSocket protocol parser error.

__init__(code, message)
class WSHandshakeError

WebSocket protocol handshake error.

_websocket_mask_python(mask, data)

Websocket masking function.

mask is a bytes object of length 4; data is a bytearray object of any length. The contents of data are masked with mask, as specified in section 5.3 of RFC 6455.

Note that this function mutates the data argument.

This pure-python implementation may be replaced by an optimized version when available.

ws_ext_parse(extstr, isserver=False)
ws_ext_gen(compress=15, isserver=False, server_notakeover=False)
class WSParserState
class WebSocketReader(queue, max_msg_size, compress=True)
__init__(queue, max_msg_size, compress=True)
feed_eof()
feed_data(data)
_feed_data(data)
parse_frame(buf)

Return the next frame from the socket.

class WebSocketWriter(protocol, transport)
__init__(protocol, transport)
_send_frame(message, opcode, compress=None)

Send a frame over the websocket with message as its payload.

pong(message=None)

Send pong message.

ping(message=None)

Send ping message.

send(message, binary=False, compress=None)

Send a frame over the websocket with message as its payload.

close(code=1000, message=None)

Close the websocket, sending the specified code and message.