summaryrefslogtreecommitdiffstats
path: root/module/lib/mod_pywebsocket/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/lib/mod_pywebsocket/__init__.py')
-rw-r--r--module/lib/mod_pywebsocket/__init__.py41
1 files changed, 27 insertions, 14 deletions
diff --git a/module/lib/mod_pywebsocket/__init__.py b/module/lib/mod_pywebsocket/__init__.py
index c154da4a1..454ae0c45 100644
--- a/module/lib/mod_pywebsocket/__init__.py
+++ b/module/lib/mod_pywebsocket/__init__.py
@@ -34,7 +34,8 @@ mod_pywebsocket is a WebSocket extension for Apache HTTP Server
intended for testing or experimental purposes. mod_python is required.
-Installation:
+Installation
+============
0. Prepare an Apache HTTP Server for which mod_python is enabled.
@@ -60,11 +61,6 @@ Installation:
<scan_dir> is useful in saving scan time when <websock_handlers>
contains many non-WebSocket handler files.
- If you want to support old handshake based on
- draft-hixie-thewebsocketprotocol-75:
-
- PythonOption mod_pywebsocket.allow_draft75 On
-
If you want to allow handlers whose canonical path is not under the root
directory (i.e. symbolic link is in root directory but its target is not),
configure as follows:
@@ -89,7 +85,8 @@ Installation:
3. Verify installation. You can use example/console.html to poke the server.
-Writing WebSocket handlers:
+Writing WebSocket handlers
+==========================
When a WebSocket request comes in, the resource name
specified in the handshake is considered as if it is a file path under
@@ -118,28 +115,36 @@ extra handshake (web_socket_do_extra_handshake):
- ws_resource
- ws_origin
- ws_version
-- ws_location (Hixie 75 and HyBi 00 only)
-- ws_extensions (Hybi 06 and later)
+- ws_location (HyBi 00 only)
+- ws_extensions (HyBi 06 and later)
- ws_deflate (HyBi 06 and later)
- ws_protocol
- ws_requested_protocols (HyBi 06 and later)
-The last two are a bit tricky.
+The last two are a bit tricky. See the next subsection.
+
+
+Subprotocol Negotiation
+-----------------------
For HyBi 06 and later, ws_protocol is always set to None when
web_socket_do_extra_handshake is called. If ws_requested_protocols is not
None, you must choose one subprotocol from this list and set it to
ws_protocol.
-For Hixie 75 and HyBi 00, when web_socket_do_extra_handshake is called,
+For HyBi 00, when web_socket_do_extra_handshake is called,
ws_protocol is set to the value given by the client in
-Sec-WebSocket-Protocol (WebSocket-Protocol for Hixie 75) header or None if
+Sec-WebSocket-Protocol header or None if
such header was not found in the opening handshake request. Finish extra
handshake with ws_protocol untouched to accept the request subprotocol.
-Then, Sec-WebSocket-Protocol (or WebSocket-Protocol) header will be sent to
+Then, Sec-WebSocket-Protocol header will be sent to
the client in response with the same value as requested. Raise an exception
in web_socket_do_extra_handshake to reject the requested subprotocol.
+
+Data Transfer
+-------------
+
web_socket_transfer_data is called after the handshake completed
successfully. A handler can receive/send messages from/to the client
using request. mod_pywebsocket.msgutil module provides utilities
@@ -159,12 +164,16 @@ You can send a message by the following statement.
request.ws_stream.send_message(message)
+
+Closing Connection
+------------------
+
Executing the following statement or just return-ing from
web_socket_transfer_data cause connection close.
request.ws_stream.close_connection()
-When you're using IETF HyBi 00 or later protocol, close_connection will wait
+close_connection will wait
for closing handshake acknowledgement coming from the client. When it
couldn't receive a valid acknowledgement, raises an exception.
@@ -176,6 +185,10 @@ use in web_socket_passive_closing_handshake.
- ws_close_code
- ws_close_reason
+
+Threading
+---------
+
A WebSocket handler must be thread-safe if the server (Apache or
standalone.py) is configured to use threads.
"""