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