1This pywebsocket code is mostly unchanged from the source at
2
3  https://github.com/GoogleChromeLabs/pywebsocket3
4
5--------------------------------------------------------------------------------
6STEPS TO UPDATE MOZILLA TO NEWER PYWEBSOCKET VERSION
7--------------------------------------------------------------------------------
8- Get new pywebsocket checkout from googlecode (into, for instance, 'src')
9
10  git clone https://github.com/GoogleChromeLabs/pywebsocket3 pywebsocket-read-only
11  cp -r pywebsocket-read-only/mod_pywebsocket testing/mochitest/pywebsocket3
12
13- hg add/rm appropriate files, and add/remove them from
14  testing/mochitest/moz.build
15
16- We need to apply the patch to hybi.py that makes HSTS work: (attached at end
17  of this README)
18
19- Test and make sure the code works:
20
21    mach mochitest dom/websocket/tests
22
23- If this doesn't take a look at the pywebsocket server log,
24  $OBJDIR/_tests/testing/mochitest/websock.log
25
26--------------------------------------------------------------------------------
27PATCH TO hybi.py for HSTS support:
28
29
30diff --git a/testing/mochitest/pywebsocket3/mod_pywebsocket/handshake/hybi.py b/testing/mochitest/pywebsocket3/mod_pywebsocket/handshake/hybi.py
31--- a/testing/mochitest/pywebsocket3/mod_pywebsocket/handshake/hybi.py
32+++ b/testing/mochitest/pywebsocket3/mod_pywebsocket/handshake/hybi.py
33@@ -273,16 +273,19 @@ class Handshaker(object):
34                 status=common.HTTP_STATUS_BAD_REQUEST)
35         raise VersionException('Unsupported version %r for header %s' %
36                                (version, common.SEC_WEBSOCKET_VERSION_HEADER),
37                                supported_versions=', '.join(
38                                    map(str, _SUPPORTED_VERSIONS)))
39
40     def _set_protocol(self):
41         self._request.ws_protocol = None
42+        # MOZILLA
43+        self._request.sts = None
44+        # /MOZILLA
45
46         protocol_header = self._request.headers_in.get(
47             common.SEC_WEBSOCKET_PROTOCOL_HEADER)
48
49         if protocol_header is None:
50             self._request.ws_requested_protocols = None
51             return
52
53@@ -371,16 +374,21 @@ class Handshaker(object):
54                 format_header(common.SEC_WEBSOCKET_PROTOCOL_HEADER,
55                               self._request.ws_protocol))
56         if (self._request.ws_extensions is not None
57                 and len(self._request.ws_extensions) != 0):
58             response.append(
59                 format_header(
60                     common.SEC_WEBSOCKET_EXTENSIONS_HEADER,
61                     common.format_extensions(self._request.ws_extensions)))
62+        # MOZILLA
63+        if self._request.sts is not None:
64+            response.append(format_header("Strict-Transport-Security",
65+                                          self._request.sts))
66+        # /MOZILLA
67
68         # Headers not specific for WebSocket
69         for name, value in self._request.extra_headers:
70             response.append(format_header(name, value))
71
72         response.append(u'\r\n')
73
74         return u''.join(response)
75