testing/mochitest/pywebsocket/README-MOZILLA

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 This pywebsocket code is mostly unchanged from the source at
     3   svn checkout http://pywebsocket.googlecode.com/svn/trunk/ pywebsocket-read-only
     5 The current Mozilla code is based on
     7   svnversion:  631  (supports RFC 6455)
     9 --------------------------------------------------------------------------------
    10 STEPS TO UPDATE MOZILLA TO NEWER PYWEBSOCKET VERSION
    11 --------------------------------------------------------------------------------
    12 - Get new pywebsocket checkout from googlecode (into, for instance, 'src')
    14   svn checkout http://pywebsocket.googlecode.com/svn/trunk/ pywebsocket-read-only
    16 - Export a version w/o SVN files:
    18     svn export src dist
    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.)
    23     rsync -rv --delete dist/ $MOZ_SRC/testing/mochitest/pywebsocket
    25 - Get rid of examples/test directory and some cruft:
    27     rm -rf example test setup.py MANIFEST.in
    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)
    32 - hg add/rm appropriate files, and add/remove them from _MOD_PYWEBSOCKET_FILES
    33   and/or _HANDSHAKE_FILES in testing/mochitest/Makefile.am
    35 - We need to apply the patch to hybi.py that makes HSTS work: (attached at end
    36   of this README)
    38 - Test and make sure the code works:
    40     make mochitest-plain TEST_PATH=content/base/test/test_websocket.html
    42 - If this doesn't take a look at the pywebsocket server log,
    43   $OBJDIR/_tests/testing/mochitest/websock.log
    45 - Upgrade the svnversion number at top of this file to whatever version we're
    46   now based off of.
    48 --------------------------------------------------------------------------------
    49 PATCH TO hybi.py for HSTS support:
    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):
    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)
    62      def _set_protocol(self):
    63          self._request.ws_protocol = None
    64 +        # MOZILLA
    65 +        self._request.sts = None
    66 +        # /MOZILLA
    68          protocol_header = self._request.headers_in.get(
    69              common.SEC_WEBSOCKET_PROTOCOL_HEADER)
    71          if not protocol_header:
    72              self._request.ws_requested_protocols = None
    73              return
    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')
    91          raw_response = ''.join(response)
    92          self._logger.debug('Opening handshake response: %r', raw_response)
    93          self._request.connection.write(raw_response)

mercurial