michael@0: This pywebsocket code is mostly unchanged from the source at michael@0: michael@0: svn checkout http://pywebsocket.googlecode.com/svn/trunk/ pywebsocket-read-only michael@0: michael@0: The current Mozilla code is based on michael@0: michael@0: svnversion: 631 (supports RFC 6455) michael@0: michael@0: -------------------------------------------------------------------------------- michael@0: STEPS TO UPDATE MOZILLA TO NEWER PYWEBSOCKET VERSION michael@0: -------------------------------------------------------------------------------- michael@0: - Get new pywebsocket checkout from googlecode (into, for instance, 'src') michael@0: michael@0: svn checkout http://pywebsocket.googlecode.com/svn/trunk/ pywebsocket-read-only michael@0: michael@0: - Export a version w/o SVN files: michael@0: michael@0: svn export src dist michael@0: michael@0: - rsync new version into our tree, deleting files that aren't needed any more michael@0: (NOTE: this will blow away this file! hg revert it or keep a copy.) michael@0: michael@0: rsync -rv --delete dist/ $MOZ_SRC/testing/mochitest/pywebsocket michael@0: michael@0: - Get rid of examples/test directory and some cruft: michael@0: michael@0: rm -rf example test setup.py MANIFEST.in michael@0: michael@0: - Manually move the 'standalone.py' file from the mmod_pywebsocket/ directory to michael@0: the parent directory (not sure why we moved it: probably no reason) michael@0: michael@0: - hg add/rm appropriate files, and add/remove them from _MOD_PYWEBSOCKET_FILES michael@0: and/or _HANDSHAKE_FILES in testing/mochitest/Makefile.am michael@0: michael@0: - We need to apply the patch to hybi.py that makes HSTS work: (attached at end michael@0: of this README) michael@0: michael@0: - Test and make sure the code works: michael@0: michael@0: make mochitest-plain TEST_PATH=content/base/test/test_websocket.html michael@0: michael@0: - If this doesn't take a look at the pywebsocket server log, michael@0: $OBJDIR/_tests/testing/mochitest/websock.log michael@0: michael@0: - Upgrade the svnversion number at top of this file to whatever version we're michael@0: now based off of. michael@0: michael@0: -------------------------------------------------------------------------------- michael@0: PATCH TO hybi.py for HSTS support: michael@0: michael@0: michael@0: diff --git a/testing/mochitest/pywebsocket/mod_pywebsocket/handshake/hybi.py b/testing/mochitest/pywebsocket/mod_pywebsocket/handshake/hybi.py michael@0: --- a/testing/mochitest/pywebsocket/mod_pywebsocket/handshake/hybi.py michael@0: +++ b/testing/mochitest/pywebsocket/mod_pywebsocket/handshake/hybi.py michael@0: @@ -227,16 +227,19 @@ class Handshaker(object): michael@0: michael@0: def _check_version(self): michael@0: unused_value = validate_mandatory_header( michael@0: self._request, common.SEC_WEBSOCKET_VERSION_HEADER, michael@0: str(common.VERSION_HYBI_LATEST), fail_status=426) michael@0: michael@0: def _set_protocol(self): michael@0: self._request.ws_protocol = None michael@0: + # MOZILLA michael@0: + self._request.sts = None michael@0: + # /MOZILLA michael@0: michael@0: protocol_header = self._request.headers_in.get( michael@0: common.SEC_WEBSOCKET_PROTOCOL_HEADER) michael@0: michael@0: if not protocol_header: michael@0: self._request.ws_requested_protocols = None michael@0: return michael@0: michael@0: @@ -311,16 +314,21 @@ class Handshaker(object): michael@0: response.append(format_header( michael@0: common.SEC_WEBSOCKET_PROTOCOL_HEADER, michael@0: self._request.ws_protocol)) michael@0: if (self._request.ws_extensions is not None and michael@0: len(self._request.ws_extensions) != 0): michael@0: response.append(format_header( michael@0: common.SEC_WEBSOCKET_EXTENSIONS_HEADER, michael@0: format_extensions(self._request.ws_extensions))) michael@0: + # MOZILLA: Add HSTS header if requested to michael@0: + if self._request.sts is not None: michael@0: + response.append(format_header("Strict-Transport-Security", michael@0: + self._request.sts)) michael@0: + # /MOZILLA michael@0: response.append('\r\n') michael@0: michael@0: raw_response = ''.join(response) michael@0: self._logger.debug('Opening handshake response: %r', raw_response) michael@0: self._request.connection.write(raw_response) michael@0: