|
1 This pywebsocket code is mostly unchanged from the source at |
|
2 |
|
3 svn checkout http://pywebsocket.googlecode.com/svn/trunk/ pywebsocket-read-only |
|
4 |
|
5 The current Mozilla code is based on |
|
6 |
|
7 svnversion: 631 (supports RFC 6455) |
|
8 |
|
9 -------------------------------------------------------------------------------- |
|
10 STEPS TO UPDATE MOZILLA TO NEWER PYWEBSOCKET VERSION |
|
11 -------------------------------------------------------------------------------- |
|
12 - Get new pywebsocket checkout from googlecode (into, for instance, 'src') |
|
13 |
|
14 svn checkout http://pywebsocket.googlecode.com/svn/trunk/ pywebsocket-read-only |
|
15 |
|
16 - Export a version w/o SVN files: |
|
17 |
|
18 svn export src dist |
|
19 |
|
20 - rsync new version into our tree, deleting files that aren't needed any more |
|
21 (NOTE: this will blow away this file! hg revert it or keep a copy.) |
|
22 |
|
23 rsync -rv --delete dist/ $MOZ_SRC/testing/mochitest/pywebsocket |
|
24 |
|
25 - Get rid of examples/test directory and some cruft: |
|
26 |
|
27 rm -rf example test setup.py MANIFEST.in |
|
28 |
|
29 - Manually move the 'standalone.py' file from the mmod_pywebsocket/ directory to |
|
30 the parent directory (not sure why we moved it: probably no reason) |
|
31 |
|
32 - hg add/rm appropriate files, and add/remove them from _MOD_PYWEBSOCKET_FILES |
|
33 and/or _HANDSHAKE_FILES in testing/mochitest/Makefile.am |
|
34 |
|
35 - We need to apply the patch to hybi.py that makes HSTS work: (attached at end |
|
36 of this README) |
|
37 |
|
38 - Test and make sure the code works: |
|
39 |
|
40 make mochitest-plain TEST_PATH=content/base/test/test_websocket.html |
|
41 |
|
42 - If this doesn't take a look at the pywebsocket server log, |
|
43 $OBJDIR/_tests/testing/mochitest/websock.log |
|
44 |
|
45 - Upgrade the svnversion number at top of this file to whatever version we're |
|
46 now based off of. |
|
47 |
|
48 -------------------------------------------------------------------------------- |
|
49 PATCH TO hybi.py for HSTS support: |
|
50 |
|
51 |
|
52 diff --git a/testing/mochitest/pywebsocket/mod_pywebsocket/handshake/hybi.py b/testing/mochitest/pywebsocket/mod_pywebsocket/handshake/hybi.py |
|
53 --- a/testing/mochitest/pywebsocket/mod_pywebsocket/handshake/hybi.py |
|
54 +++ b/testing/mochitest/pywebsocket/mod_pywebsocket/handshake/hybi.py |
|
55 @@ -227,16 +227,19 @@ class Handshaker(object): |
|
56 |
|
57 def _check_version(self): |
|
58 unused_value = validate_mandatory_header( |
|
59 self._request, common.SEC_WEBSOCKET_VERSION_HEADER, |
|
60 str(common.VERSION_HYBI_LATEST), fail_status=426) |
|
61 |
|
62 def _set_protocol(self): |
|
63 self._request.ws_protocol = None |
|
64 + # MOZILLA |
|
65 + self._request.sts = None |
|
66 + # /MOZILLA |
|
67 |
|
68 protocol_header = self._request.headers_in.get( |
|
69 common.SEC_WEBSOCKET_PROTOCOL_HEADER) |
|
70 |
|
71 if not protocol_header: |
|
72 self._request.ws_requested_protocols = None |
|
73 return |
|
74 |
|
75 @@ -311,16 +314,21 @@ class Handshaker(object): |
|
76 response.append(format_header( |
|
77 common.SEC_WEBSOCKET_PROTOCOL_HEADER, |
|
78 self._request.ws_protocol)) |
|
79 if (self._request.ws_extensions is not None and |
|
80 len(self._request.ws_extensions) != 0): |
|
81 response.append(format_header( |
|
82 common.SEC_WEBSOCKET_EXTENSIONS_HEADER, |
|
83 format_extensions(self._request.ws_extensions))) |
|
84 + # MOZILLA: Add HSTS header if requested to |
|
85 + if self._request.sts is not None: |
|
86 + response.append(format_header("Strict-Transport-Security", |
|
87 + self._request.sts)) |
|
88 + # /MOZILLA |
|
89 response.append('\r\n') |
|
90 |
|
91 raw_response = ''.join(response) |
|
92 self._logger.debug('Opening handshake response: %r', raw_response) |
|
93 self._request.connection.write(raw_response) |
|
94 |