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 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 self.ChromiumSyncBirthdayErrorOpHandler, |
| 1409 self.ChromiumSyncTransientErrorOpHandler] |
| 1410 |
1409 post_handlers = [self.ChromiumSyncCommandHandler, | 1411 post_handlers = [self.ChromiumSyncCommandHandler, |
1410 self.ChromiumSyncTimeHandler] | 1412 self.ChromiumSyncTimeHandler] |
1411 BasePageHandler.__init__(self, request, client_address, | 1413 BasePageHandler.__init__(self, request, client_address, |
1412 sync_http_server, [], get_handlers, | 1414 sync_http_server, [], get_handlers, |
1413 post_handlers, []) | 1415 post_handlers, []) |
1414 | 1416 |
1415 def ChromiumSyncTimeHandler(self): | 1417 def ChromiumSyncTimeHandler(self): |
1416 """Handle Chromium sync .../time requests. | 1418 """Handle Chromium sync .../time requests. |
1417 | 1419 |
1418 The syncer sometimes checks server reachability by examining /time. | 1420 The syncer sometimes checks server reachability by examining /time. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1473 if not self._ShouldHandleRequest(test_name): | 1475 if not self._ShouldHandleRequest(test_name): |
1474 return False | 1476 return False |
1475 result, raw_reply = self.server._sync_handler.HandleCreateBirthdayError() | 1477 result, raw_reply = self.server._sync_handler.HandleCreateBirthdayError() |
1476 self.send_response(result) | 1478 self.send_response(result) |
1477 self.send_header('Content-Type', 'text/html') | 1479 self.send_header('Content-Type', 'text/html') |
1478 self.send_header('Content-Length', len(raw_reply)) | 1480 self.send_header('Content-Length', len(raw_reply)) |
1479 self.end_headers() | 1481 self.end_headers() |
1480 self.wfile.write(raw_reply) | 1482 self.wfile.write(raw_reply) |
1481 return True; | 1483 return True; |
1482 | 1484 |
| 1485 def ChromiumSyncTransientErrorOpHandler(self): |
| 1486 test_name = "/chromiumsync/transienterror" |
| 1487 if not self._ShouldHandleRequest(test_name): |
| 1488 return False |
| 1489 result, raw_reply = self.server._sync_handler.HandleSetTransientError() |
| 1490 self.send_response(result) |
| 1491 self.send_header('Content-Type', 'text/html') |
| 1492 self.send_header('Content-Length', len(raw_reply)) |
| 1493 self.end_headers() |
| 1494 self.wfile.write(raw_reply) |
| 1495 return True; |
| 1496 |
1483 | 1497 |
1484 def MakeDataDir(): | 1498 def MakeDataDir(): |
1485 if options.data_dir: | 1499 if options.data_dir: |
1486 if not os.path.isdir(options.data_dir): | 1500 if not os.path.isdir(options.data_dir): |
1487 print 'specified data dir not found: ' + options.data_dir + ' exiting...' | 1501 print 'specified data dir not found: ' + options.data_dir + ' exiting...' |
1488 return None | 1502 return None |
1489 my_data_dir = options.data_dir | 1503 my_data_dir = options.data_dir |
1490 else: | 1504 else: |
1491 # Create the default path to our data dir, relative to the exe dir. | 1505 # Create the default path to our data dir, relative to the exe dir. |
1492 my_data_dir = os.path.dirname(sys.argv[0]) | 1506 my_data_dir = os.path.dirname(sys.argv[0]) |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1713 'random key if none is specified on the command ' | 1727 'random key if none is specified on the command ' |
1714 'line.') | 1728 'line.') |
1715 option_parser.add_option('', '--policy-user', default='user@example.com', | 1729 option_parser.add_option('', '--policy-user', default='user@example.com', |
1716 dest='policy_user', | 1730 dest='policy_user', |
1717 help='Specify the user name the server should ' | 1731 help='Specify the user name the server should ' |
1718 'report back to the client as the user owning the ' | 1732 'report back to the client as the user owning the ' |
1719 'token used for making the policy request.') | 1733 'token used for making the policy request.') |
1720 options, args = option_parser.parse_args() | 1734 options, args = option_parser.parse_args() |
1721 | 1735 |
1722 sys.exit(main(options, args)) | 1736 sys.exit(main(options, args)) |
OLD | NEW |