| OLD | NEW |
| 1 #!/usr/bin/python2.4 | 1 #!/usr/bin/python2.4 |
| 2 # Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """This is a simple HTTP server used for testing Chrome. | 6 """This is a simple HTTP server used for testing Chrome. |
| 7 | 7 |
| 8 It supports several test URLs, as specified by the handlers in TestPageHandler. | 8 It supports several test URLs, as specified by the handlers in TestPageHandler. |
| 9 By default, it listens on an ephemeral port and sends the port number back to | 9 By default, it listens on an ephemeral port and sends the port number back to |
| 10 the originating process over a pipe. The originating process can specify an | 10 the originating process over a pipe. The originating process can specify an |
| (...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 def write(self, text) : | 1381 def write(self, text) : |
| 1382 self.__fd1.write(text) | 1382 self.__fd1.write(text) |
| 1383 self.__fd2.write(text) | 1383 self.__fd2.write(text) |
| 1384 | 1384 |
| 1385 def flush(self) : | 1385 def flush(self) : |
| 1386 self.__fd1.flush() | 1386 self.__fd1.flush() |
| 1387 self.__fd2.flush() | 1387 self.__fd2.flush() |
| 1388 | 1388 |
| 1389 def main(options, args): | 1389 def main(options, args): |
| 1390 logfile = open('testserver.log', 'w') | 1390 logfile = open('testserver.log', 'w') |
| 1391 sys.stdout = FileMultiplexer(sys.stdout, logfile) | |
| 1392 sys.stderr = FileMultiplexer(sys.stderr, logfile) | 1391 sys.stderr = FileMultiplexer(sys.stderr, logfile) |
| 1392 if options.log_to_console: |
| 1393 sys.stdout = FileMultiplexer(sys.stdout, logfile) |
| 1394 else: |
| 1395 sys.stdout = logfile |
| 1393 | 1396 |
| 1394 port = options.port | 1397 port = options.port |
| 1395 | 1398 |
| 1396 server_data = {} | 1399 server_data = {} |
| 1397 | 1400 |
| 1398 if options.server_type == SERVER_HTTP: | 1401 if options.server_type == SERVER_HTTP: |
| 1399 if options.cert: | 1402 if options.cert: |
| 1400 # let's make sure the cert file exists. | 1403 # let's make sure the cert file exists. |
| 1401 if not os.path.isfile(options.cert): | 1404 if not os.path.isfile(options.cert): |
| 1402 print 'specified server cert file not found: ' + options.cert + \ | 1405 print 'specified server cert file not found: ' + options.cert + \ |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1480 if __name__ == '__main__': | 1483 if __name__ == '__main__': |
| 1481 option_parser = optparse.OptionParser() | 1484 option_parser = optparse.OptionParser() |
| 1482 option_parser.add_option("-f", '--ftp', action='store_const', | 1485 option_parser.add_option("-f", '--ftp', action='store_const', |
| 1483 const=SERVER_FTP, default=SERVER_HTTP, | 1486 const=SERVER_FTP, default=SERVER_HTTP, |
| 1484 dest='server_type', | 1487 dest='server_type', |
| 1485 help='start up an FTP server.') | 1488 help='start up an FTP server.') |
| 1486 option_parser.add_option('', '--sync', action='store_const', | 1489 option_parser.add_option('', '--sync', action='store_const', |
| 1487 const=SERVER_SYNC, default=SERVER_HTTP, | 1490 const=SERVER_SYNC, default=SERVER_HTTP, |
| 1488 dest='server_type', | 1491 dest='server_type', |
| 1489 help='start up a sync server.') | 1492 help='start up a sync server.') |
| 1493 option_parser.add_option('', '--log-to-console', action='store_const', |
| 1494 const=True, default=False, |
| 1495 dest='log_to_console', |
| 1496 help='Enables or disables sys.stdout logging to ' |
| 1497 'the console.') |
| 1490 option_parser.add_option('', '--port', default='0', type='int', | 1498 option_parser.add_option('', '--port', default='0', type='int', |
| 1491 help='Port used by the server. If unspecified, the ' | 1499 help='Port used by the server. If unspecified, the ' |
| 1492 'server will listen on an ephemeral port.') | 1500 'server will listen on an ephemeral port.') |
| 1493 option_parser.add_option('', '--data-dir', dest='data_dir', | 1501 option_parser.add_option('', '--data-dir', dest='data_dir', |
| 1494 help='Directory from which to read the files.') | 1502 help='Directory from which to read the files.') |
| 1495 option_parser.add_option('', '--https', dest='cert', | 1503 option_parser.add_option('', '--https', dest='cert', |
| 1496 help='Specify that https should be used, specify ' | 1504 help='Specify that https should be used, specify ' |
| 1497 'the path to the cert containing the private key ' | 1505 'the path to the cert containing the private key ' |
| 1498 'the server should use.') | 1506 'the server should use.') |
| 1499 option_parser.add_option('', '--ssl-client-auth', action='store_true', | 1507 option_parser.add_option('', '--ssl-client-auth', action='store_true', |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1513 'option may appear multiple times, indicating ' | 1521 'option may appear multiple times, indicating ' |
| 1514 'multiple algorithms should be enabled.'); | 1522 'multiple algorithms should be enabled.'); |
| 1515 option_parser.add_option('', '--file-root-url', default='/files/', | 1523 option_parser.add_option('', '--file-root-url', default='/files/', |
| 1516 help='Specify a root URL for files served.') | 1524 help='Specify a root URL for files served.') |
| 1517 option_parser.add_option('', '--startup-pipe', type='int', | 1525 option_parser.add_option('', '--startup-pipe', type='int', |
| 1518 dest='startup_pipe', | 1526 dest='startup_pipe', |
| 1519 help='File handle of pipe to parent process') | 1527 help='File handle of pipe to parent process') |
| 1520 options, args = option_parser.parse_args() | 1528 options, args = option_parser.parse_args() |
| 1521 | 1529 |
| 1522 sys.exit(main(options, args)) | 1530 sys.exit(main(options, args)) |
| OLD | NEW |