Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(743)

Side by Side Diff: net/tools/testserver/testserver.py

Issue 7811026: Python server to test the actionable error feature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For review. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/UDP/ server used for testing Chrome. 6 """This is a simple HTTP/FTP/SYNC/TCP/UDP/ 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 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 1401
1402 1402
1403 class SyncPageHandler(BasePageHandler): 1403 class SyncPageHandler(BasePageHandler):
1404 """Handler for the main HTTP sync server.""" 1404 """Handler for the main HTTP sync server."""
1405 1405
1406 def __init__(self, request, client_address, sync_http_server): 1406 def __init__(self, request, client_address, sync_http_server):
1407 get_handlers = [self.ChromiumSyncMigrationOpHandler, 1407 get_handlers = [self.ChromiumSyncMigrationOpHandler,
1408 self.ChromiumSyncTimeHandler, 1408 self.ChromiumSyncTimeHandler,
1409 self.ChromiumSyncBirthdayErrorOpHandler, 1409 self.ChromiumSyncBirthdayErrorOpHandler,
1410 self.ChromiumSyncTransientErrorOpHandler, 1410 self.ChromiumSyncTransientErrorOpHandler,
1411 self.ChromiumSyncSyncTabsOpHandler] 1411 self.ChromiumSyncSyncTabsOpHandler,
1412 self.ChromiumSyncErrorOpHandler]
1412 1413
1413 post_handlers = [self.ChromiumSyncCommandHandler, 1414 post_handlers = [self.ChromiumSyncCommandHandler,
1414 self.ChromiumSyncTimeHandler] 1415 self.ChromiumSyncTimeHandler]
1415 BasePageHandler.__init__(self, request, client_address, 1416 BasePageHandler.__init__(self, request, client_address,
1416 sync_http_server, [], get_handlers, 1417 sync_http_server, [], get_handlers,
1417 post_handlers, []) 1418 post_handlers, [])
1418 1419
1419 def ChromiumSyncTimeHandler(self): 1420 def ChromiumSyncTimeHandler(self):
1420 """Handle Chromium sync .../time requests. 1421 """Handle Chromium sync .../time requests.
1421 1422
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 if not self._ShouldHandleRequest(test_name): 1490 if not self._ShouldHandleRequest(test_name):
1490 return False 1491 return False
1491 result, raw_reply = self.server._sync_handler.HandleSetTransientError() 1492 result, raw_reply = self.server._sync_handler.HandleSetTransientError()
1492 self.send_response(result) 1493 self.send_response(result)
1493 self.send_header('Content-Type', 'text/html') 1494 self.send_header('Content-Type', 'text/html')
1494 self.send_header('Content-Length', len(raw_reply)) 1495 self.send_header('Content-Length', len(raw_reply))
1495 self.end_headers() 1496 self.end_headers()
1496 self.wfile.write(raw_reply) 1497 self.wfile.write(raw_reply)
1497 return True; 1498 return True;
1498 1499
1500 def ChromiumSyncErrorOpHandler(self):
1501 test_name = "/chromiumsync/error"
1502 if not self._ShouldHandleRequest(test_name):
1503 return False
1504 result, raw_reply = self.server._sync_handler.HandleSetError(
1505 self.path)
1506 self.send_response(result)
1507 self.send_header('Content-Type', 'text/html')
1508 self.send_header('Content-Length', len(raw_reply))
1509 self.end_headers()
1510 self.wfile.write(raw_reply)
1511 return True;
1512
1499 def ChromiumSyncSyncTabsOpHandler(self): 1513 def ChromiumSyncSyncTabsOpHandler(self):
1500 test_name = "/chromiumsync/synctabs" 1514 test_name = "/chromiumsync/synctabs"
1501 if not self._ShouldHandleRequest(test_name): 1515 if not self._ShouldHandleRequest(test_name):
1502 return False 1516 return False
1503 result, raw_reply = self.server._sync_handler.HandleSetSyncTabs() 1517 result, raw_reply = self.server._sync_handler.HandleSetSyncTabs()
1504 self.send_response(result) 1518 self.send_response(result)
1505 self.send_header('Content-Type', 'text/html') 1519 self.send_header('Content-Type', 'text/html')
1506 self.send_header('Content-Length', len(raw_reply)) 1520 self.send_header('Content-Length', len(raw_reply))
1507 self.end_headers() 1521 self.end_headers()
1508 self.wfile.write(raw_reply) 1522 self.wfile.write(raw_reply)
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1766 'random key if none is specified on the command ' 1780 'random key if none is specified on the command '
1767 'line.') 1781 'line.')
1768 option_parser.add_option('', '--policy-user', default='user@example.com', 1782 option_parser.add_option('', '--policy-user', default='user@example.com',
1769 dest='policy_user', 1783 dest='policy_user',
1770 help='Specify the user name the server should ' 1784 help='Specify the user name the server should '
1771 'report back to the client as the user owning the ' 1785 'report back to the client as the user owning the '
1772 'token used for making the policy request.') 1786 'token used for making the policy request.')
1773 options, args = option_parser.parse_args() 1787 options, args = option_parser.parse_args()
1774 1788
1775 sys.exit(main(options, args)) 1789 sys.exit(main(options, args))
OLDNEW
« net/tools/testserver/chromiumsync.py ('K') | « net/tools/testserver/chromiumsync.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698