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