testing/mochitest/pywebsocket/README-MOZILLA

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/testing/mochitest/pywebsocket/README-MOZILLA	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,94 @@
     1.4 +This pywebsocket code is mostly unchanged from the source at
     1.5 +
     1.6 +  svn checkout http://pywebsocket.googlecode.com/svn/trunk/ pywebsocket-read-only
     1.7 +
     1.8 +The current Mozilla code is based on
     1.9 +
    1.10 +  svnversion:  631  (supports RFC 6455)
    1.11 +
    1.12 +--------------------------------------------------------------------------------
    1.13 +STEPS TO UPDATE MOZILLA TO NEWER PYWEBSOCKET VERSION
    1.14 +--------------------------------------------------------------------------------
    1.15 +- Get new pywebsocket checkout from googlecode (into, for instance, 'src')
    1.16 +
    1.17 +  svn checkout http://pywebsocket.googlecode.com/svn/trunk/ pywebsocket-read-only
    1.18 +
    1.19 +- Export a version w/o SVN files:
    1.20 +
    1.21 +    svn export src dist
    1.22 +
    1.23 +- rsync new version into our tree, deleting files that aren't needed any more
    1.24 +  (NOTE: this will blow away this file!  hg revert it or keep a copy.)
    1.25 +
    1.26 +    rsync -rv --delete dist/ $MOZ_SRC/testing/mochitest/pywebsocket
    1.27 +
    1.28 +- Get rid of examples/test directory and some cruft:
    1.29 +
    1.30 +    rm -rf example test setup.py MANIFEST.in
    1.31 +
    1.32 +- Manually move the 'standalone.py' file from the mmod_pywebsocket/ directory to
    1.33 +  the parent directory (not sure why we moved it: probably no reason)
    1.34 +
    1.35 +- hg add/rm appropriate files, and add/remove them from _MOD_PYWEBSOCKET_FILES
    1.36 +  and/or _HANDSHAKE_FILES in testing/mochitest/Makefile.am
    1.37 +
    1.38 +- We need to apply the patch to hybi.py that makes HSTS work: (attached at end
    1.39 +  of this README)
    1.40 +
    1.41 +- Test and make sure the code works:
    1.42 +
    1.43 +    make mochitest-plain TEST_PATH=content/base/test/test_websocket.html
    1.44 +
    1.45 +- If this doesn't take a look at the pywebsocket server log,
    1.46 +  $OBJDIR/_tests/testing/mochitest/websock.log
    1.47 +
    1.48 +- Upgrade the svnversion number at top of this file to whatever version we're
    1.49 +  now based off of.
    1.50 +
    1.51 +--------------------------------------------------------------------------------
    1.52 +PATCH TO hybi.py for HSTS support:
    1.53 +
    1.54 +
    1.55 +diff --git a/testing/mochitest/pywebsocket/mod_pywebsocket/handshake/hybi.py b/testing/mochitest/pywebsocket/mod_pywebsocket/handshake/hybi.py
    1.56 +--- a/testing/mochitest/pywebsocket/mod_pywebsocket/handshake/hybi.py
    1.57 ++++ b/testing/mochitest/pywebsocket/mod_pywebsocket/handshake/hybi.py
    1.58 +@@ -227,16 +227,19 @@ class Handshaker(object):
    1.59 + 
    1.60 +     def _check_version(self):
    1.61 +         unused_value = validate_mandatory_header(
    1.62 +             self._request, common.SEC_WEBSOCKET_VERSION_HEADER,
    1.63 +             str(common.VERSION_HYBI_LATEST), fail_status=426)
    1.64 + 
    1.65 +     def _set_protocol(self):
    1.66 +         self._request.ws_protocol = None
    1.67 ++        # MOZILLA
    1.68 ++        self._request.sts = None
    1.69 ++        # /MOZILLA
    1.70 + 
    1.71 +         protocol_header = self._request.headers_in.get(
    1.72 +             common.SEC_WEBSOCKET_PROTOCOL_HEADER)
    1.73 + 
    1.74 +         if not protocol_header:
    1.75 +             self._request.ws_requested_protocols = None
    1.76 +             return
    1.77 + 
    1.78 +@@ -311,16 +314,21 @@ class Handshaker(object):
    1.79 +             response.append(format_header(
    1.80 +                 common.SEC_WEBSOCKET_PROTOCOL_HEADER,
    1.81 +                 self._request.ws_protocol))
    1.82 +         if (self._request.ws_extensions is not None and
    1.83 +             len(self._request.ws_extensions) != 0):
    1.84 +             response.append(format_header(
    1.85 +                 common.SEC_WEBSOCKET_EXTENSIONS_HEADER,
    1.86 +                 format_extensions(self._request.ws_extensions)))
    1.87 ++        # MOZILLA: Add HSTS header if requested to
    1.88 ++        if self._request.sts is not None:
    1.89 ++            response.append(format_header("Strict-Transport-Security",
    1.90 ++                                          self._request.sts))
    1.91 ++        # /MOZILLA
    1.92 +         response.append('\r\n')
    1.93 + 
    1.94 +         raw_response = ''.join(response)
    1.95 +         self._logger.debug('Opening handshake response: %r', raw_response)
    1.96 +         self._request.connection.write(raw_response)
    1.97 +

mercurial