| Differences between
and this patch
- WebKitTools/ChangeLog +23 lines
Lines 1-3 WebKitTools/ChangeLog_sec1
1
2010-02-17  Fumitoshi Ukai  <ukai@chromium.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        pywebsocket should support html and cgi in the same directory.
6
        https://bugs.webkit.org/show_bug.cgi?id=34879
7
8
        Import pywebsocket 0.4.9.
9
        Specify --server-host 127.0.0.1, so that it only binds listening socket
10
        to 127.0.0.1 to prevent access from non-localhost.
11
        Change --cgi-paths from /websocket/tests/cookies to /websocket/tests,
12
        because pywebsocket 0.4.9.1 supports html and cgi in the same directory
13
        and only executable (httponly-cookies.pl) will be handled as cgi
14
        script.
15
16
        * Scripts/run-webkit-tests:
17
        * Scripts/run-webkit-websocketserver:
18
        * Scripts/webkitpy/layout_tests/port/websocket_server.py:
19
        * pywebsocket/mod_pywebsocket/standalone.py:
20
        * pywebsocket/example/echo_client.py
21
        * pywebsocket/example/handler_map.txt
22
        * pywebsocket/setup.py:
23
1
2010-02-20  Chris Jerdonek  <cjerdonek@webkit.org>
24
2010-02-20  Chris Jerdonek  <cjerdonek@webkit.org>
2
25
3
        Reviewed by Adam Barth.
26
        Reviewed by Adam Barth.
- WebKitTools/Scripts/run-webkit-tests -6 / +7 lines
Lines 1394-1405 sub openWebSocketServerIfNeeded() WebKitTools/Scripts/run-webkit-tests_sec1
1394
1394
1395
    my @args = (
1395
    my @args = (
1396
        "WebKitTools/pywebsocket/mod_pywebsocket/standalone.py",
1396
        "WebKitTools/pywebsocket/mod_pywebsocket/standalone.py",
1397
        "-p", "$webSocketPort",
1397
        "--server-host", "127.0.0.1",
1398
        "-d", "$webSocketHandlerDir",
1398
        "--port", "$webSocketPort",
1399
        "-s", "$webSocketHandlerScanDir",
1399
        "--document-root", "$webSocketHandlerDir",
1400
        "-m", "$webSocketHandlerMapFile",
1400
        "--scan-dir", "$webSocketHandlerScanDir",
1401
        "-x", "/websocket/tests/cookies",
1401
        "--websock-handlers-map-file", "$webSocketHandlerMapFile",
1402
        "-l", "$logFile",
1402
        "--cgi-paths", "/websocket/tests",
1403
        "--log-file", "$logFile",
1403
        "--strict",
1404
        "--strict",
1404
    );
1405
    );
1405
    # wss is disabled until all platforms support pyOpenSSL.
1406
    # wss is disabled until all platforms support pyOpenSSL.
- WebKitTools/Scripts/run-webkit-websocketserver -5 / +6 lines
Lines 71-81 sub openWebSocketServer() WebKitTools/Scripts/run-webkit-websocketserver_sec1
71
71
72
    my @args = (
72
    my @args = (
73
        "$srcDir/WebKitTools/pywebsocket/mod_pywebsocket/standalone.py",
73
        "$srcDir/WebKitTools/pywebsocket/mod_pywebsocket/standalone.py",
74
        "-p", "$webSocketPort",
74
        "--server-host", "127.0.0.1",
75
        "-d", "$webSocketHandlerDir",
75
        "--port", "$webSocketPort",
76
        "-s", "$webSocketHandlerScanDir",
76
        "--document-root", "$webSocketHandlerDir",
77
        "-m", "$webSocketHandlerMapFile",
77
        "--scan-dir", "$webSocketHandlerScanDir",
78
        "-x", "/websocket/tests/cookies",
78
        "--websock-handlers-map-file", "$webSocketHandlerMapFile",
79
        "--cgi-paths", "/websocket/tests",
79
    );
80
    );
80
81
81
    $ENV{"PYTHONPATH"} = $webSocketPythonPath;
82
    $ENV{"PYTHONPATH"} = $webSocketPythonPath;
- WebKitTools/Scripts/webkitpy/layout_tests/port/websocket_server.py -6 / +7 lines
Lines 156-173 class PyWebSocket(http_server.Lighttpd): WebKitTools/Scripts/webkitpy/layout_tests/port/websocket_server.py_sec1
156
            'standalone.py')
156
            'standalone.py')
157
        start_cmd = [
157
        start_cmd = [
158
            python_interp, pywebsocket_script,
158
            python_interp, pywebsocket_script,
159
            '-p', str(self._port),
159
            '--server-host', '127.0.0.1',
160
            '-d', self._layout_tests,
160
            '--port', str(self._port),
161
            '-s', self._web_socket_tests,
161
            '--document-root', self._layout_tests,
162
            '-x', '/websocket/tests/cookies',
162
            '--scan-dir', self._web_socket_tests,
163
            '-l', error_log,
163
            '--cgi-paths', '/websocket/tests',
164
            '--log-file', error_log,
164
        ]
165
        ]
165
166
166
        handler_map_file = os.path.join(self._web_socket_tests,
167
        handler_map_file = os.path.join(self._web_socket_tests,
167
                                        'handler_map.txt')
168
                                        'handler_map.txt')
168
        if os.path.exists(handler_map_file):
169
        if os.path.exists(handler_map_file):
169
            logging.debug('Using handler_map_file: %s' % handler_map_file)
170
            logging.debug('Using handler_map_file: %s' % handler_map_file)
170
            start_cmd.append('-m')
171
            start_cmd.append('--websock-handlers-map-file')
171
            start_cmd.append(handler_map_file)
172
            start_cmd.append(handler_map_file)
172
        else:
173
        else:
173
            logging.warning('No handler_map_file found')
174
            logging.warning('No handler_map_file found')
- WebKitTools/pywebsocket/setup.py -1 / +1 lines
Lines 56-62 setup(author='Yuzo Fujishima', WebKitTools/pywebsocket/setup.py_sec1
56
      name=_PACKAGE_NAME,
56
      name=_PACKAGE_NAME,
57
      packages=[_PACKAGE_NAME],
57
      packages=[_PACKAGE_NAME],
58
      url='http://code.google.com/p/pywebsocket/',
58
      url='http://code.google.com/p/pywebsocket/',
59
      version='0.4.8',
59
      version='0.4.9.1',
60
      )
60
      )
61
61
62
62
- WebKitTools/pywebsocket/example/echo_client.py -4 / +6 lines
Lines 163-171 def main(): WebKitTools/pywebsocket/example/echo_client.py_sec1
163
    sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
163
    sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
164
164
165
    parser = OptionParser()
165
    parser = OptionParser()
166
    parser.add_option('-s', '--server_host', dest='server_host', type='string',
166
    parser.add_option('-s', '--server-host', '--server_host',
167
                      dest='server_host', type='string',
167
                      default='localhost', help='server host')
168
                      default='localhost', help='server host')
168
    parser.add_option('-p', '--server_port', dest='server_port', type='int',
169
    parser.add_option('-p', '--server-port', '--server_port',
170
                      dest='server_port', type='int',
169
                      default=_UNDEFINED_PORT, help='server port')
171
                      default=_UNDEFINED_PORT, help='server port')
170
    parser.add_option('-o', '--origin', dest='origin', type='string',
172
    parser.add_option('-o', '--origin', dest='origin', type='string',
171
                      default='http://localhost/', help='origin')
173
                      default='http://localhost/', help='origin')
Lines 179-186 def main(): WebKitTools/pywebsocket/example/echo_client.py_sec2
179
                      default=True, help='suppress messages')
181
                      default=True, help='suppress messages')
180
    parser.add_option('-t', '--tls', dest='use_tls', action='store_true',
182
    parser.add_option('-t', '--tls', dest='use_tls', action='store_true',
181
                      default=False, help='use TLS (wss://)')
183
                      default=False, help='use TLS (wss://)')
182
    parser.add_option('-k', '--socket_timeout', dest='socket_timeout',
184
    parser.add_option('-k', '--socket-timeout', '--socket_timeout',
183
                      type='int', default=_TIMEOUT_SEC,
185
                      dest='socket_timeout', type='int', default=_TIMEOUT_SEC,
184
                      help='Timeout(sec) for sockets')
186
                      help='Timeout(sec) for sockets')
185
187
186
    (options, unused_args) = parser.parse_args()
188
    (options, unused_args) = parser.parse_args()
- WebKitTools/pywebsocket/example/handler_map.txt +11 lines
Line 0 WebKitTools/pywebsocket/example/handler_map.txt_sec1
1
# websocket handler map file, used by standalone.py -m option.
2
# A line starting with '#' is a comment line.
3
# Each line consists of 'alias_resource_path' and 'existing_resource_path'
4
# separated by spaces.
5
# Aliasing is processed from the top to the bottom of the line, and
6
# 'existing_resource_path' must exist before it is aliased.
7
# For example,
8
#  / /echo
9
# means that a request to '/' will be handled by handlers for '/echo'.
10
/ /echo
11
- WebKitTools/pywebsocket/mod_pywebsocket/standalone.py -15 / +36 lines
Lines 55-60 under scan_dir are scanned. This is usef WebKitTools/pywebsocket/mod_pywebsocket/standalone.py_sec1
55
Note:
55
Note:
56
This server is derived from SocketServer.ThreadingMixIn. Hence a thread is
56
This server is derived from SocketServer.ThreadingMixIn. Hence a thread is
57
used for each request.
57
used for each request.
58
59
SECURITY WARNING: This uses CGIHTTPServer and CGIHTTPServer is not secure.
60
It may execute arbitrary Python code or external programs. It should not be
61
used outside a firewall.
58
"""
62
"""
59
63
60
import BaseHTTPServer
64
import BaseHTTPServer
Lines 272-281 class WebSocketRequestHandler(CGIHTTPSer WebKitTools/pywebsocket/mod_pywebsocket/standalone.py_sec2
272
    def is_cgi(self):
276
    def is_cgi(self):
273
        """Test whether self.path corresponds to a CGI script.
277
        """Test whether self.path corresponds to a CGI script.
274
278
275
        Add extra check that self.path doesn't contains .."""
279
        Add extra check that self.path doesn't contains ..
280
        Also check if the file is a executable file or not.
281
        If the file is not executable, it is handled as static file or dir
282
        rather than a CGI script.
283
        """
276
        if CGIHTTPServer.CGIHTTPRequestHandler.is_cgi(self):
284
        if CGIHTTPServer.CGIHTTPRequestHandler.is_cgi(self):
277
            if '..' in self.path:
285
            if '..' in self.path:
278
                return False
286
                return False
287
            scriptfile = self.translate_path(self.path.split('?', 2)[0])
288
            if not os.path.isfile(scriptfile):
289
                return False
290
            if not self.is_executable(scriptfile):
291
                return False
279
            return True
292
            return True
280
        return False
293
        return False
281
294
Lines 321-346 def _alias_handlers(dispatcher, websock_ WebKitTools/pywebsocket/mod_pywebsocket/standalone.py_sec3
321
334
322
def _main():
335
def _main():
323
    parser = optparse.OptionParser()
336
    parser = optparse.OptionParser()
337
    parser.add_option('-H', '--server-host', '--server_host',
338
                      dest='server_host',
339
                      default='',
340
                      help='server hostname to listen to')
324
    parser.add_option('-p', '--port', dest='port', type='int',
341
    parser.add_option('-p', '--port', dest='port', type='int',
325
                      default=handshake._DEFAULT_WEB_SOCKET_PORT,
342
                      default=handshake._DEFAULT_WEB_SOCKET_PORT,
326
                      help='port to listen to')
343
                      help='port to listen to')
327
    parser.add_option('-w', '--websock_handlers', dest='websock_handlers',
344
    parser.add_option('-w', '--websock-handlers', '--websock_handlers',
345
                      dest='websock_handlers',
328
                      default='.',
346
                      default='.',
329
                      help='Web Socket handlers root directory.')
347
                      help='Web Socket handlers root directory.')
330
    parser.add_option('-m', '--websock_handlers_map_file',
348
    parser.add_option('-m', '--websock-handlers-map-file',
349
                      '--websock_handlers_map_file',
331
                      dest='websock_handlers_map_file',
350
                      dest='websock_handlers_map_file',
332
                      default=None,
351
                      default=None,
333
                      help=('Web Socket handlers map file. '
352
                      help=('Web Socket handlers map file. '
334
                            'Each line consists of alias_resource_path and '
353
                            'Each line consists of alias_resource_path and '
335
                            'existing_resource_path, separated by spaces.'))
354
                            'existing_resource_path, separated by spaces.'))
336
    parser.add_option('-s', '--scan_dir', dest='scan_dir',
355
    parser.add_option('-s', '--scan-dir', '--scan_dir', dest='scan_dir',
337
                      default=None,
356
                      default=None,
338
                      help=('Web Socket handlers scan directory. '
357
                      help=('Web Socket handlers scan directory. '
339
                            'Must be a directory under websock_handlers.'))
358
                            'Must be a directory under websock_handlers.'))
340
    parser.add_option('-d', '--document_root', dest='document_root',
359
    parser.add_option('-d', '--document-root', '--document_root',
341
                      default='.',
360
                      dest='document_root', default='.',
342
                      help='Document root directory.')
361
                      help='Document root directory.')
343
    parser.add_option('-x', '--cgi_paths', dest='cgi_paths',
362
    parser.add_option('-x', '--cgi-paths', '--cgi_paths', dest='cgi_paths',
344
                      default=None,
363
                      default=None,
345
                      help=('CGI paths relative to document_root.'
364
                      help=('CGI paths relative to document_root.'
346
                            'Comma-separated. (e.g -x /cgi,/htbin) '
365
                            'Comma-separated. (e.g -x /cgi,/htbin) '
Lines 348-368 def _main(): WebKitTools/pywebsocket/mod_pywebsocket/standalone.py_sec4
348
                            'as CGI programs. Must be executable.'))
367
                            'as CGI programs. Must be executable.'))
349
    parser.add_option('-t', '--tls', dest='use_tls', action='store_true',
368
    parser.add_option('-t', '--tls', dest='use_tls', action='store_true',
350
                      default=False, help='use TLS (wss://)')
369
                      default=False, help='use TLS (wss://)')
351
    parser.add_option('-k', '--private_key', dest='private_key',
370
    parser.add_option('-k', '--private-key', '--private_key',
371
                      dest='private_key',
352
                      default='', help='TLS private key file.')
372
                      default='', help='TLS private key file.')
353
    parser.add_option('-c', '--certificate', dest='certificate',
373
    parser.add_option('-c', '--certificate', dest='certificate',
354
                      default='', help='TLS certificate file.')
374
                      default='', help='TLS certificate file.')
355
    parser.add_option('-l', '--log_file', dest='log_file',
375
    parser.add_option('-l', '--log-file', '--log_file', dest='log_file',
356
                      default='', help='Log file.')
376
                      default='', help='Log file.')
357
    parser.add_option('--log_level', type='choice', dest='log_level',
377
    parser.add_option('--log-level', '--log_level', type='choice',
358
                      default='warn',
378
                      dest='log_level', default='warn',
359
                      choices=['debug', 'info', 'warn', 'error', 'critical'],
379
                      choices=['debug', 'info', 'warn', 'error', 'critical'],
360
                      help='Log level.')
380
                      help='Log level.')
361
    parser.add_option('--log_max', dest='log_max', type='int',
381
    parser.add_option('--log-max', '--log_max', dest='log_max', type='int',
362
                      default=_DEFAULT_LOG_MAX_BYTES,
382
                      default=_DEFAULT_LOG_MAX_BYTES,
363
                      help='Log maximum bytes')
383
                      help='Log maximum bytes')
364
    parser.add_option('--log_count', dest='log_count', type='int',
384
    parser.add_option('--log-count', '--log_count', dest='log_count',
365
                      default=_DEFAULT_LOG_BACKUP_COUNT,
385
                      type='int', default=_DEFAULT_LOG_BACKUP_COUNT,
366
                      help='Log backup count')
386
                      help='Log backup count')
367
    parser.add_option('--strict', dest='strict', action='store_true',
387
    parser.add_option('--strict', dest='strict', action='store_true',
368
                      default=False, help='Strictly check handshake request')
388
                      default=False, help='Strictly check handshake request')
Lines 407-413 def _main(): WebKitTools/pywebsocket/mod_pywebsocket/standalone.py_sec5
407
        WebSocketRequestHandler.options = options
427
        WebSocketRequestHandler.options = options
408
        WebSocketServer.options = options
428
        WebSocketServer.options = options
409
429
410
        server = WebSocketServer(('', options.port), WebSocketRequestHandler)
430
        server = WebSocketServer((options.server_host, options.port),
431
                                 WebSocketRequestHandler)
411
        server.serve_forever()
432
        server.serve_forever()
412
    except Exception, e:
433
    except Exception, e:
413
        logging.critical(str(e))
434
        logging.critical(str(e))
- LayoutTests/ChangeLog +12 lines
Lines 1-3 LayoutTests/ChangeLog_sec1
1
2010-02-17  Fumitoshi Ukai  <ukai@chromium.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        pywebsocket should support html and cgi in the same directory.
6
        https://bugs.webkit.org/show_bug.cgi?id=34879
7
    
8
        * websocket/tests/cookies/httponly-cookie.pl: Removed.
9
        * websocket/tests/echo-cookie_wsh.py: Renamed from LayoutTests/websocket/tests/cookies/echo-cookie_wsh.py.
10
        * websocket/tests/httponly-cookie-expected.txt: Renamed from LayoutTests/websocket/tests/cookies/httponly-cookie-expected.txt.
11
        * websocket/tests/httponly-cookie.pl: Added.
12
1
2010-02-07  Yuzo Fujishima  <yuzo@google.com>
13
2010-02-07  Yuzo Fujishima  <yuzo@google.com>
2
14
3
        Reviewed by Eric Seidel.
15
        Reviewed by Eric Seidel.
- LayoutTests/websocket/tests/echo-cookie_wsh.py +36 lines
Line 0 LayoutTests/websocket/tests/echo-cookie_wsh.py_sec1
1
# Copyright (C) 2010 Google Inc. All rights reserved.
2
#
3
# Redistribution and use in source and binary forms, with or without
4
# modification, are permitted provided that the following conditions are
5
# met:
6
#
7
#     * Redistributions of source code must retain the above copyright
8
# notice, this list of conditions and the following disclaimer.
9
#     * Redistributions in binary form must reproduce the above
10
# copyright notice, this list of conditions and the following disclaimer
11
# in the documentation and/or other materials provided with the
12
# distribution.
13
#     * Neither the name of Google Inc. nor the names of its
14
# contributors may be used to endorse or promote products derived from
15
# this software without specific prior written permission.
16
#
17
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29
30
from mod_pywebsocket import msgutil
31
32
def web_socket_do_extra_handshake(request):
33
    pass
34
35
def web_socket_transfer_data(request):
36
    msgutil.send_message(request,  request.headers_in['Cookie'])
- LayoutTests/websocket/tests/httponly-cookie-expected.txt +11 lines
Line 0 LayoutTests/websocket/tests/httponly-cookie-expected.txt_sec1
1
Test WebSocket sends HttpOnly cookies.
2
3
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4
5
WebSocket open
6
WebSocket closed
7
PASS cookie is "WK-websocket-test=1; WK-websocket-test-httponly=1"
8
PASS successfullyParsed is true
9
10
TEST COMPLETE
11
- LayoutTests/websocket/tests/httponly-cookie.pl +51 lines
Line 0 LayoutTests/websocket/tests/httponly-cookie.pl_sec1
1
#!/usr/bin/perl -wT
2
use strict;
3
4
print "Content-Type: text/html\r\n";
5
print "Set-Cookie: WK-websocket-test=1\r\n";
6
print "Set-Cookie: WK-websocket-test-httponly=1; HttpOnly\r\n";
7
print "\r\n";
8
print <<HTML
9
<html>
10
<head>
11
<script src="../../../fast/js/resources/js-test-pre.js"></script>
12
<script src="../../../fast/js/resources/js-test-post-function.js"></script>
13
</head>
14
<body>
15
<p>Test WebSocket sends HttpOnly cookies.</p>
16
<p>On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".</p>
17
<div id="console"></div>
18
<script>
19
if (window.layoutTestController) {
20
    layoutTestController.dumpAsText();
21
    layoutTestController.waitUntilDone();
22
}
23
24
var cookie;
25
26
function endTest()
27
{
28
    shouldBe("cookie", '"WK-websocket-test=1; WK-websocket-test-httponly=1"');
29
    isSuccessfullyParsed();
30
    if (window.layoutTestController)
31
       layoutTestController.notifyDone();
32
}
33
34
var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/cookies/echo-cookie");
35
ws.onopen = function() {
36
    debug("WebSocket open");
37
};
38
ws.onmessage = function(evt) {
39
    cookie = evt.data;
40
    ws.close();
41
};
42
ws.onclose = function() {
43
    debug("WebSocket closed");
44
    endTest();
45
};
46
47
var successfullyParsed = true;
48
</script>
49
</body>
50
</html>
51
HTML
- LayoutTests/websocket/tests/httponly-cookie.pl -3 / +3 lines
Lines 8-15 print "\r\n"; LayoutTests/websocket/tests/httponly-cookie.pl_sec1
8
print <<HTML
8
print <<HTML
9
<html>
9
<html>
10
<head>
10
<head>
11
<script src="../../../fast/js/resources/js-test-pre.js"></script>
11
<script src="../../fast/js/resources/js-test-pre.js"></script>
12
<script src="../../../fast/js/resources/js-test-post-function.js"></script>
12
<script src="../../fast/js/resources/js-test-post-function.js"></script>
13
</head>
13
</head>
14
<body>
14
<body>
15
<p>Test WebSocket sends HttpOnly cookies.</p>
15
<p>Test WebSocket sends HttpOnly cookies.</p>
Lines 31-37 function endTest() LayoutTests/websocket/tests/httponly-cookie.pl_sec2
31
       layoutTestController.notifyDone();
31
       layoutTestController.notifyDone();
32
}
32
}
33
33
34
var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/cookies/echo-cookie");
34
var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/echo-cookie");
35
ws.onopen = function() {
35
ws.onopen = function() {
36
    debug("WebSocket open");
36
    debug("WebSocket open");
37
};
37
};
- LayoutTests/websocket/tests/cookies/echo-cookie_wsh.py -36 lines
Lines 1-36 LayoutTests/websocket/tests/cookies/echo-cookie_wsh.py_sec1
1
# Copyright (C) 2010 Google Inc. All rights reserved.
2
#
3
# Redistribution and use in source and binary forms, with or without
4
# modification, are permitted provided that the following conditions are
5
# met:
6
#
7
#     * Redistributions of source code must retain the above copyright
8
# notice, this list of conditions and the following disclaimer.
9
#     * Redistributions in binary form must reproduce the above
10
# copyright notice, this list of conditions and the following disclaimer
11
# in the documentation and/or other materials provided with the
12
# distribution.
13
#     * Neither the name of Google Inc. nor the names of its
14
# contributors may be used to endorse or promote products derived from
15
# this software without specific prior written permission.
16
#
17
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29
30
from mod_pywebsocket import msgutil
31
32
def web_socket_do_extra_handshake(request):
33
    pass
34
35
def web_socket_transfer_data(request):
36
    msgutil.send_message(request,  request.headers_in['Cookie'])
- LayoutTests/websocket/tests/cookies/httponly-cookie-expected.txt -11 lines
Lines 1-11 LayoutTests/websocket/tests/cookies/httponly-cookie-expected.txt_sec1
1
Test WebSocket sends HttpOnly cookies.
2
3
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4
5
WebSocket open
6
WebSocket closed
7
PASS cookie is "WK-websocket-test=1; WK-websocket-test-httponly=1"
8
PASS successfullyParsed is true
9
10
TEST COMPLETE
11
- LayoutTests/websocket/tests/cookies/httponly-cookie.pl -51 lines
Lines 1-51 LayoutTests/websocket/tests/cookies/httponly-cookie.pl_sec1
1
#!/usr/bin/perl -wT
2
use strict;
3
4
print "Content-Type: text/html\r\n";
5
print "Set-Cookie: WK-websocket-test=1\r\n";
6
print "Set-Cookie: WK-websocket-test-httponly=1; HttpOnly\r\n";
7
print "\r\n";
8
print <<HTML
9
<html>
10
<head>
11
<script src="../../../fast/js/resources/js-test-pre.js"></script>
12
<script src="../../../fast/js/resources/js-test-post-function.js"></script>
13
</head>
14
<body>
15
<p>Test WebSocket sends HttpOnly cookies.</p>
16
<p>On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".</p>
17
<div id="console"></div>
18
<script>
19
if (window.layoutTestController) {
20
    layoutTestController.dumpAsText();
21
    layoutTestController.waitUntilDone();
22
}
23
24
var cookie;
25
26
function endTest()
27
{
28
    shouldBe("cookie", '"WK-websocket-test=1; WK-websocket-test-httponly=1"');
29
    isSuccessfullyParsed();
30
    if (window.layoutTestController)
31
       layoutTestController.notifyDone();
32
}
33
34
var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/cookies/echo-cookie");
35
ws.onopen = function() {
36
    debug("WebSocket open");
37
};
38
ws.onmessage = function(evt) {
39
    cookie = evt.data;
40
    ws.close();
41
};
42
ws.onclose = function() {
43
    debug("WebSocket closed");
44
    endTest();
45
};
46
47
var successfullyParsed = true;
48
</script>
49
</body>
50
</html>
51
HTML

Return to Bug 34879