OLD | NEW |
1 #!/usr/bin/python2.4 | 1 #!/usr/bin/python2.4 |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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/FTP/SYNC/TCP ECHO/UDP ECHO/ server used for testing | 6 """This is a simple HTTP/FTP/SYNC/TCP ECHO/UDP ECHO/ server used for testing |
7 Chrome. | 7 Chrome. |
8 | 8 |
9 It supports several test URLs, as specified by the handlers in TestPageHandler. | 9 It supports several test URLs, as specified by the handlers in TestPageHandler. |
10 By default, it listens on an ephemeral port and sends the port number back to | 10 By default, it listens on an ephemeral port and sends the port number back to |
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 self.wfile.write('%X\r\n' % len(chunk)) | 1397 self.wfile.write('%X\r\n' % len(chunk)) |
1398 self.wfile.write(chunk) | 1398 self.wfile.write(chunk) |
1399 self.wfile.write('\r\n') | 1399 self.wfile.write('\r\n') |
1400 | 1400 |
1401 | 1401 |
1402 class SyncPageHandler(BasePageHandler): | 1402 class SyncPageHandler(BasePageHandler): |
1403 """Handler for the main HTTP sync server.""" | 1403 """Handler for the main HTTP sync server.""" |
1404 | 1404 |
1405 def __init__(self, request, client_address, sync_http_server): | 1405 def __init__(self, request, client_address, sync_http_server): |
1406 get_handlers = [self.ChromiumSyncMigrationOpHandler, | 1406 get_handlers = [self.ChromiumSyncMigrationOpHandler, |
1407 self.ChromiumSyncTimeHandler] | 1407 self.ChromiumSyncTimeHandler, |
| 1408 self.ChromiumSyncBirthdayErrorOpHandler] |
1408 post_handlers = [self.ChromiumSyncCommandHandler, | 1409 post_handlers = [self.ChromiumSyncCommandHandler, |
1409 self.ChromiumSyncTimeHandler] | 1410 self.ChromiumSyncTimeHandler] |
1410 BasePageHandler.__init__(self, request, client_address, | 1411 BasePageHandler.__init__(self, request, client_address, |
1411 sync_http_server, [], get_handlers, | 1412 sync_http_server, [], get_handlers, |
1412 post_handlers, []) | 1413 post_handlers, []) |
1413 | 1414 |
1414 def ChromiumSyncTimeHandler(self): | 1415 def ChromiumSyncTimeHandler(self): |
1415 """Handle Chromium sync .../time requests. | 1416 """Handle Chromium sync .../time requests. |
1416 | 1417 |
1417 The syncer sometimes checks server reachability by examining /time. | 1418 The syncer sometimes checks server reachability by examining /time. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 | 1461 |
1461 http_response, raw_reply = self.server._sync_handler.HandleMigrate( | 1462 http_response, raw_reply = self.server._sync_handler.HandleMigrate( |
1462 self.path) | 1463 self.path) |
1463 self.send_response(http_response) | 1464 self.send_response(http_response) |
1464 self.send_header('Content-Type', 'text/html') | 1465 self.send_header('Content-Type', 'text/html') |
1465 self.send_header('Content-Length', len(raw_reply)) | 1466 self.send_header('Content-Length', len(raw_reply)) |
1466 self.end_headers() | 1467 self.end_headers() |
1467 self.wfile.write(raw_reply) | 1468 self.wfile.write(raw_reply) |
1468 return True | 1469 return True |
1469 | 1470 |
| 1471 def ChromiumSyncBirthdayErrorOpHandler(self): |
| 1472 test_name = "/chromiumsync/birthdayerror" |
| 1473 if not self._ShouldHandleRequest(test_name): |
| 1474 return False |
| 1475 result, raw_reply = self.server._sync_handler.HandleCreateBirthdayError() |
| 1476 self.send_response(result) |
| 1477 self.send_header('Content-Type', 'text/html') |
| 1478 self.send_header('Content-Length', len(raw_reply)) |
| 1479 self.end_headers() |
| 1480 self.wfile.write(raw_reply) |
| 1481 return True; |
| 1482 |
1470 | 1483 |
1471 def MakeDataDir(): | 1484 def MakeDataDir(): |
1472 if options.data_dir: | 1485 if options.data_dir: |
1473 if not os.path.isdir(options.data_dir): | 1486 if not os.path.isdir(options.data_dir): |
1474 print 'specified data dir not found: ' + options.data_dir + ' exiting...' | 1487 print 'specified data dir not found: ' + options.data_dir + ' exiting...' |
1475 return None | 1488 return None |
1476 my_data_dir = options.data_dir | 1489 my_data_dir = options.data_dir |
1477 else: | 1490 else: |
1478 # Create the default path to our data dir, relative to the exe dir. | 1491 # Create the default path to our data dir, relative to the exe dir. |
1479 my_data_dir = os.path.dirname(sys.argv[0]) | 1492 my_data_dir = os.path.dirname(sys.argv[0]) |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1700 'random key if none is specified on the command ' | 1713 'random key if none is specified on the command ' |
1701 'line.') | 1714 'line.') |
1702 option_parser.add_option('', '--policy-user', default='user@example.com', | 1715 option_parser.add_option('', '--policy-user', default='user@example.com', |
1703 dest='policy_user', | 1716 dest='policy_user', |
1704 help='Specify the user name the server should ' | 1717 help='Specify the user name the server should ' |
1705 'report back to the client as the user owning the ' | 1718 'report back to the client as the user owning the ' |
1706 'token used for making the policy request.') | 1719 'token used for making the policy request.') |
1707 options, args = option_parser.parse_args() | 1720 options, args = option_parser.parse_args() |
1708 | 1721 |
1709 sys.exit(main(options, args)) | 1722 sys.exit(main(options, args)) |
OLD | NEW |