Changeset 55719 in webkit


Ignore:
Timestamp:
Mar 9, 2010 2:40:49 AM (14 years ago)
Author:
ukai@chromium.org
Message:

2010-03-03 Fumitoshi Ukai <ukai@chromium.org>

Reviewed by Alexey Proskuryakov.

pywebsocket should support html and cgi in the same directory.
https://bugs.webkit.org/show_bug.cgi?id=34879

  • websocket/tests/cookies: Removed.
  • websocket/tests/cookies/echo-cookie_wsh.py: Removed.
  • websocket/tests/cookies/httponly-cookie-expected.txt: Removed.
  • websocket/tests/cookies/httponly-cookie.pl: Removed.
  • websocket/tests/echo-cookie_wsh.py: Copied from LayoutTests/websocket/tests/cookies/echo-cookie_wsh.py.
  • websocket/tests/httponly-cookie-expected.txt: Copied from LayoutTests/websocket/tests/cookies/httponly-cookie-expected.txt.
  • websocket/tests/httponly-cookie.pl: Copied from LayoutTests/websocket/tests/cookies/httponly-cookie.pl.

2010-03-03 Fumitoshi Ukai <ukai@chromium.org>

Reviewed by Alexey Proskuryakov.

pywebsocket should support html and cgi in the same directory.
https://bugs.webkit.org/show_bug.cgi?id=34879

Import pywebsocket 0.4.9.2
Specify --server-host 127.0.0.1, so that it only binds listening socket
to 127.0.0.1 to prevent access from non-localhost.
Change --cgi-paths from /websocket/tests/cookies to /websocket/tests,
because pywebsocket 0.4.9.2 supports html and cgi in the same directory
and only executable (httponly-cookies.pl) will be handled as cgi
script.

  • Scripts/run-webkit-tests:
  • Scripts/run-webkit-websocketserver:
  • Scripts/webkitpy/layout_tests/port/websocket_server.py:
  • Scripts/webkitpy/thirdparty/pywebsocket/README.webkit:
  • Scripts/webkitpy/thirdparty/pywebsocket/example/echo_client.py:
  • Scripts/webkitpy/thirdparty/pywebsocket/example/handler_map.txt: Added.
  • Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/standalone.py:
  • Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/util.py:
  • Scripts/webkitpy/thirdparty/pywebsocket/setup.py:
  • Scripts/webkitpy/thirdparty/pywebsocket/test/test_util.py:
  • Scripts/webkitpy/thirdparty/pywebsocket/test/testdata/README: Added.
  • Scripts/webkitpy/thirdparty/pywebsocket/test/testdata/hello.pl: Added.
Location:
trunk
Files:
3 added
1 deleted
11 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r55711 r55719  
     12010-03-03  Fumitoshi Ukai  <ukai@chromium.org>
     2
     3        Reviewed by Alexey Proskuryakov.
     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: Removed.
     9        * websocket/tests/cookies/echo-cookie_wsh.py: Removed.
     10        * websocket/tests/cookies/httponly-cookie-expected.txt: Removed.
     11        * websocket/tests/cookies/httponly-cookie.pl: Removed.
     12        * websocket/tests/echo-cookie_wsh.py: Copied from LayoutTests/websocket/tests/cookies/echo-cookie_wsh.py.
     13        * websocket/tests/httponly-cookie-expected.txt: Copied from LayoutTests/websocket/tests/cookies/httponly-cookie-expected.txt.
     14        * websocket/tests/httponly-cookie.pl: Copied from LayoutTests/websocket/tests/cookies/httponly-cookie.pl.
     15
    1162010-03-08  Kent Tamura  <tkent@chromium.org>
    217
  • trunk/LayoutTests/websocket/tests/httponly-cookie.pl

    r55360 r55719  
    99<html>
    1010<head>
    11 <script src="../../../fast/js/resources/js-test-pre.js"></script>
    12 <script src="../../../fast/js/resources/js-test-post-function.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>
    1313</head>
    1414<body>
     
    3232}
    3333
    34 var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/cookies/echo-cookie");
     34var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/echo-cookie");
    3535ws.onopen = function() {
    3636    debug("WebSocket open");
  • trunk/WebKitTools/ChangeLog

    r55715 r55719  
     12010-03-03  Fumitoshi Ukai  <ukai@chromium.org>
     2
     3        Reviewed by Alexey Proskuryakov.
     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.2
     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.2 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        * Scripts/webkitpy/thirdparty/pywebsocket/README.webkit:
     20        * Scripts/webkitpy/thirdparty/pywebsocket/example/echo_client.py:
     21        * Scripts/webkitpy/thirdparty/pywebsocket/example/handler_map.txt: Added.
     22        * Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/standalone.py:
     23        * Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/util.py:
     24        * Scripts/webkitpy/thirdparty/pywebsocket/setup.py:
     25        * Scripts/webkitpy/thirdparty/pywebsocket/test/test_util.py:
     26        * Scripts/webkitpy/thirdparty/pywebsocket/test/testdata/README: Added.
     27        * Scripts/webkitpy/thirdparty/pywebsocket/test/testdata/hello.pl: Added.
     28
    1292010-03-09  Chris Jerdonek  <cjerdonek@webkit.org>
    230
  • trunk/WebKitTools/Scripts/run-webkit-tests

    r55663 r55719  
    14271427    my @args = (
    14281428        "WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/standalone.py",
    1429         "-p", "$webSocketPort",
    1430         "-d", "$webSocketHandlerDir",
    1431         "-s", "$webSocketHandlerScanDir",
    1432         "-m", "$webSocketHandlerMapFile",
    1433         "-x", "/websocket/tests/cookies",
    1434         "-l", "$logFile",
     1429        "--server-host", "127.0.0.1",
     1430        "--port", "$webSocketPort",
     1431        "--document-root", "$webSocketHandlerDir",
     1432        "--scan-dir", "$webSocketHandlerScanDir",
     1433        "--websock-handlers-map-file", "$webSocketHandlerMapFile",
     1434        "--cgi-paths", "/websocket/tests",
     1435        "--log-file", "$logFile",
    14351436        "--strict",
    14361437    );
  • trunk/WebKitTools/Scripts/run-webkit-websocketserver

    r55286 r55719  
    7272    my @args = (
    7373        "$srcDir/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/standalone.py",
    74         "-p", "$webSocketPort",
    75         "-d", "$webSocketHandlerDir",
    76         "-s", "$webSocketHandlerScanDir",
    77         "-m", "$webSocketHandlerMapFile",
    78         "-x", "/websocket/tests/cookies",
     74        "--server-host", "127.0.0.1",
     75        "--port", "$webSocketPort",
     76        "--document-root", "$webSocketHandlerDir",
     77        "--scan-dir", "$webSocketHandlerScanDir",
     78        "--websock-handlers-map-file", "$webSocketHandlerMapFile",
     79        "--cgi-paths", "/websocket/tests/cookies",
    7980    );
    8081
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/websocket_server.py

    r55603 r55719  
    159159        start_cmd = [
    160160            python_interp, pywebsocket_script,
    161             '-p', str(self._port),
    162             '-d', self._layout_tests,
    163             '-s', self._web_socket_tests,
    164             '-x', '/websocket/tests/cookies',
    165             '-l', error_log,
     161            '--server-host', '127.0.0.1',
     162            '--port', str(self._port),
     163            '--document-root', self._layout_tests,
     164            '--scan-dir', self._web_socket_tests,
     165            '--cgi-paths', '/websocket/tests/cookies',
     166            '--log-file', error_log,
    166167        ]
    167168
     
    170171        if os.path.exists(handler_map_file):
    171172            _log.debug('Using handler_map_file: %s' % handler_map_file)
    172             start_cmd.append('-m')
     173            start_cmd.append('--websock-handlers-map-file')
    173174            start_cmd.append(handler_map_file)
    174175        else:
  • trunk/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/README.webkit

    r55286 r55719  
    55
    66This directory currently contains the following version:
    7 FIXME: Fill in the current version here.
     70.4.9.2
    88
    99The following modifications have been made to this local version:
    10 FIXME: Fill in local modifications.
     10minor updates in WebSocketRequestHandler.is_cgi
    1111
    1212More information on these local modifications can be found here:
  • trunk/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/example/echo_client.py

    r51406 r55719  
    164164
    165165    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',
    167168                      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',
    169171                      default=_UNDEFINED_PORT, help='server port')
    170172    parser.add_option('-o', '--origin', dest='origin', type='string',
     
    180182    parser.add_option('-t', '--tls', dest='use_tls', action='store_true',
    181183                      default=False, help='use TLS (wss://)')
    182     parser.add_option('-k', '--socket_timeout', dest='socket_timeout',
    183                       type='int', default=_TIMEOUT_SEC,
     184    parser.add_option('-k', '--socket-timeout', '--socket_timeout',
     185                      dest='socket_timeout', type='int', default=_TIMEOUT_SEC,
    184186                      help='Timeout(sec) for sockets')
    185187
  • trunk/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/standalone.py

    r54707 r55719  
    273273        """Test whether self.path corresponds to a CGI script.
    274274
    275         Add extra check that self.path doesn't contains .."""
     275        Add extra check that self.path doesn't contains ..
     276        Also check if the file is a executable file or not.
     277        If the file is not executable, it is handled as static file or dir
     278        rather than a CGI script.
     279        """
    276280        if CGIHTTPServer.CGIHTTPRequestHandler.is_cgi(self):
    277281            if '..' in self.path:
     282                return False
     283            # strip query parameter from request path
     284            resource_name = self.path.split('?', 2)[0]
     285            # convert resource_name into real path name in filesystem.
     286            scriptfile = self.translate_path(resource_name)
     287            if not os.path.isfile(scriptfile):
     288                return False
     289            if not self.is_executable(scriptfile):
    278290                return False
    279291            return True
     
    322334def _main():
    323335    parser = optparse.OptionParser()
     336    parser.add_option('-H', '--server-host', '--server_host',
     337                      dest='server_host',
     338                      default='',
     339                      help='server hostname to listen to')
    324340    parser.add_option('-p', '--port', dest='port', type='int',
    325341                      default=handshake._DEFAULT_WEB_SOCKET_PORT,
    326342                      help='port to listen to')
    327     parser.add_option('-w', '--websock_handlers', dest='websock_handlers',
     343    parser.add_option('-w', '--websock-handlers', '--websock_handlers',
     344                      dest='websock_handlers',
    328345                      default='.',
    329346                      help='Web Socket handlers root directory.')
    330     parser.add_option('-m', '--websock_handlers_map_file',
     347    parser.add_option('-m', '--websock-handlers-map-file',
     348                      '--websock_handlers_map_file',
    331349                      dest='websock_handlers_map_file',
    332350                      default=None,
     
    334352                            'Each line consists of alias_resource_path and '
    335353                            'existing_resource_path, separated by spaces.'))
    336     parser.add_option('-s', '--scan_dir', dest='scan_dir',
     354    parser.add_option('-s', '--scan-dir', '--scan_dir', dest='scan_dir',
    337355                      default=None,
    338356                      help=('Web Socket handlers scan directory. '
    339357                            'Must be a directory under websock_handlers.'))
    340     parser.add_option('-d', '--document_root', dest='document_root',
    341                       default='.',
     358    parser.add_option('-d', '--document-root', '--document_root',
     359                      dest='document_root', default='.',
    342360                      help='Document root directory.')
    343     parser.add_option('-x', '--cgi_paths', dest='cgi_paths',
     361    parser.add_option('-x', '--cgi-paths', '--cgi_paths', dest='cgi_paths',
    344362                      default=None,
    345363                      help=('CGI paths relative to document_root.'
     
    349367    parser.add_option('-t', '--tls', dest='use_tls', action='store_true',
    350368                      default=False, help='use TLS (wss://)')
    351     parser.add_option('-k', '--private_key', dest='private_key',
     369    parser.add_option('-k', '--private-key', '--private_key',
     370                      dest='private_key',
    352371                      default='', help='TLS private key file.')
    353372    parser.add_option('-c', '--certificate', dest='certificate',
    354373                      default='', help='TLS certificate file.')
    355     parser.add_option('-l', '--log_file', dest='log_file',
     374    parser.add_option('-l', '--log-file', '--log_file', dest='log_file',
    356375                      default='', help='Log file.')
    357     parser.add_option('--log_level', type='choice', dest='log_level',
    358                       default='warn',
     376    parser.add_option('--log-level', '--log_level', type='choice',
     377                      dest='log_level', default='warn',
    359378                      choices=['debug', 'info', 'warn', 'error', 'critical'],
    360379                      help='Log level.')
    361     parser.add_option('--log_max', dest='log_max', type='int',
     380    parser.add_option('--log-max', '--log_max', dest='log_max', type='int',
    362381                      default=_DEFAULT_LOG_MAX_BYTES,
    363382                      help='Log maximum bytes')
    364     parser.add_option('--log_count', dest='log_count', type='int',
    365                       default=_DEFAULT_LOG_BACKUP_COUNT,
     383    parser.add_option('--log-count', '--log_count', dest='log_count',
     384                      type='int', default=_DEFAULT_LOG_BACKUP_COUNT,
    366385                      help='Log backup count')
    367386    parser.add_option('--strict', dest='strict', action='store_true',
     
    382401        CGIHTTPServer.CGIHTTPRequestHandler.cgi_directories = \
    383402            options.cgi_paths.split(',')
     403        if sys.platform in ('cygwin', 'win32'):
     404            cygwin_path = None
     405            # For Win32 Python, it is expected that CYGWIN_PATH
     406            # is set to a directory of cygwin binaries.
     407            # For example, websocket_server.py in Chromium sets CYGWIN_PATH to
     408            # full path of third_party/cygwin/bin.
     409            if 'CYGWIN_PATH' in os.environ:
     410                cygwin_path = os.environ['CYGWIN_PATH']
     411            util.wrap_popen3_for_win(cygwin_path)
     412            def __check_script(scriptpath):
     413                return util.get_script_interp(scriptpath, cygwin_path)
     414            CGIHTTPServer.executable = __check_script
    384415
    385416    if options.use_tls:
     
    408439        WebSocketServer.options = options
    409440
    410         server = WebSocketServer(('', options.port), WebSocketRequestHandler)
     441        server = WebSocketServer((options.server_host, options.port),
     442                                 WebSocketRequestHandler)
    411443        server.serve_forever()
    412444    except Exception, e:
  • trunk/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/mod_pywebsocket/util.py

    r51661 r55719  
    3434
    3535import StringIO
     36import os
     37import re
    3638import traceback
    3739
     
    5759
    5860
     61def __translate_interp(interp, cygwin_path):
     62    """Translate interp program path for Win32 python to run cygwin program
     63    (e.g. perl).  Note that it doesn't support path that contains space,
     64    which is typically true for Unix, where #!-script is written.
     65    For Win32 python, cygwin_path is a directory of cygwin binaries.
     66
     67    Args:
     68      interp: interp command line
     69      cygwin_path: directory name of cygwin binary, or None
     70    Returns:
     71      translated interp command line.
     72    """
     73    if not cygwin_path:
     74        return interp
     75    m = re.match("^[^ ]*/([^ ]+)( .*)?", interp)
     76    if m:
     77        cmd = os.path.join(cygwin_path, m.group(1))
     78        return cmd + m.group(2)
     79    return interp
     80
     81
     82def get_script_interp(script_path, cygwin_path=None):
     83    """Gets #!-interpreter command line from the script.
     84
     85    It also fixes command path.  When Cygwin Python is used, e.g. in WebKit,
     86    it could run "/usr/bin/perl -wT hello.pl".
     87    When Win32 Python is used, e.g. in Chromium, it couldn't.  So, fix
     88    "/usr/bin/perl" to "<cygwin_path>\perl.exe".
     89
     90    Args:
     91      script_path: pathname of the script
     92      cygwin_path: directory name of cygwin binary, or None
     93    Returns:
     94      #!-interpreter command line, or None if it is not #!-script.
     95    """
     96    fp = open(script_path)
     97    line = fp.readline()
     98    fp.close()
     99    m = re.match("^#!(.*)", line)
     100    if m:
     101        return __translate_interp(m.group(1), cygwin_path)
     102    return None
     103
     104def wrap_popen3_for_win(cygwin_path):
     105    """Wrap popen3 to support #!-script on Windows.
     106
     107    Args:
     108      cygwin_path:  path for cygwin binary if command path is needed to be
     109                    translated.  None if no translation required.
     110    """
     111    __orig_popen3 = os.popen3
     112    def __wrap_popen3(cmd, mode='t', bufsize=-1):
     113        cmdline = cmd.split(' ')
     114        interp = get_script_interp(cmdline[0], cygwin_path)
     115        if interp:
     116            cmd = interp + " " + cmd
     117        return __orig_popen3(cmd, mode, bufsize)
     118    os.popen3 = __wrap_popen3
     119
     120
    59121# vi:sts=4 sw=4 et
  • trunk/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/setup.py

    r54707 r55719  
    5757      packages=[_PACKAGE_NAME],
    5858      url='http://code.google.com/p/pywebsocket/',
    59       version='0.4.8',
     59      version='0.4.9.2',
    6060      )
    6161
  • trunk/WebKitTools/Scripts/webkitpy/thirdparty/pywebsocket/test/test_util.py

    r51661 r55719  
    3434
    3535
     36import os
     37import sys
    3638import unittest
    3739
     
    3941from mod_pywebsocket import util
    4042
     43_TEST_DATA_DIR = os.path.join(os.path.split(__file__)[0], 'testdata')
    4144
    4245class UtilTest(unittest.TestCase):
     
    5659        self.assertEqual('Hello World', str(exc))
    5760
     61    def test_get_script_interp(self):
     62        cygwin_path = 'c:\\cygwin\\bin'
     63        cygwin_perl = os.path.join(cygwin_path, 'perl')
     64        self.assertEqual(None, util.get_script_interp(
     65            os.path.join(_TEST_DATA_DIR, 'README')))
     66        self.assertEqual(None, util.get_script_interp(
     67            os.path.join(_TEST_DATA_DIR, 'README'), cygwin_path))
     68        self.assertEqual('/usr/bin/perl -wT', util.get_script_interp(
     69            os.path.join(_TEST_DATA_DIR, 'hello.pl')))
     70        self.assertEqual(cygwin_perl + ' -wT', util.get_script_interp(
     71            os.path.join(_TEST_DATA_DIR, 'hello.pl'), cygwin_path))
     72
    5873
    5974if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.