OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1642 # Each chunk consists of: chunk size (hex), CRLF, chunk body, CRLF | 1642 # Each chunk consists of: chunk size (hex), CRLF, chunk body, CRLF |
1643 self.wfile.write('%X\r\n' % len(chunk)) | 1643 self.wfile.write('%X\r\n' % len(chunk)) |
1644 self.wfile.write(chunk) | 1644 self.wfile.write(chunk) |
1645 self.wfile.write('\r\n') | 1645 self.wfile.write('\r\n') |
1646 | 1646 |
1647 | 1647 |
1648 class SyncPageHandler(BasePageHandler): | 1648 class SyncPageHandler(BasePageHandler): |
1649 """Handler for the main HTTP sync server.""" | 1649 """Handler for the main HTTP sync server.""" |
1650 | 1650 |
1651 def __init__(self, request, client_address, sync_http_server): | 1651 def __init__(self, request, client_address, sync_http_server): |
1652 get_handlers = [self.ChromiumSyncMigrationOpHandler, | 1652 get_handlers = [self.ChromiumSyncTimeHandler, |
1653 self.ChromiumSyncTimeHandler, | 1653 self.ChromiumSyncMigrationOpHandler, |
| 1654 self.ChromiumSyncCredHandler, |
1654 self.ChromiumSyncDisableNotificationsOpHandler, | 1655 self.ChromiumSyncDisableNotificationsOpHandler, |
1655 self.ChromiumSyncEnableNotificationsOpHandler, | 1656 self.ChromiumSyncEnableNotificationsOpHandler, |
1656 self.ChromiumSyncSendNotificationOpHandler, | 1657 self.ChromiumSyncSendNotificationOpHandler, |
1657 self.ChromiumSyncBirthdayErrorOpHandler, | 1658 self.ChromiumSyncBirthdayErrorOpHandler, |
1658 self.ChromiumSyncTransientErrorOpHandler, | 1659 self.ChromiumSyncTransientErrorOpHandler, |
| 1660 self.ChromiumSyncErrorOpHandler, |
1659 self.ChromiumSyncSyncTabsOpHandler, | 1661 self.ChromiumSyncSyncTabsOpHandler, |
1660 self.ChromiumSyncErrorOpHandler, | 1662 self.ChromiumSyncCreateSyncedBookmarksOpHandler] |
1661 self.ChromiumSyncCredHandler] | |
1662 | 1663 |
1663 post_handlers = [self.ChromiumSyncCommandHandler, | 1664 post_handlers = [self.ChromiumSyncCommandHandler, |
1664 self.ChromiumSyncTimeHandler] | 1665 self.ChromiumSyncTimeHandler] |
1665 BasePageHandler.__init__(self, request, client_address, | 1666 BasePageHandler.__init__(self, request, client_address, |
1666 sync_http_server, [], get_handlers, [], | 1667 sync_http_server, [], get_handlers, [], |
1667 post_handlers, []) | 1668 post_handlers, []) |
1668 | 1669 |
1669 | 1670 |
1670 def ChromiumSyncTimeHandler(self): | 1671 def ChromiumSyncTimeHandler(self): |
1671 """Handle Chromium sync .../time requests. | 1672 """Handle Chromium sync .../time requests. |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1851 if not self._ShouldHandleRequest(test_name): | 1852 if not self._ShouldHandleRequest(test_name): |
1852 return False | 1853 return False |
1853 result, raw_reply = self.server._sync_handler.HandleSetSyncTabs() | 1854 result, raw_reply = self.server._sync_handler.HandleSetSyncTabs() |
1854 self.send_response(result) | 1855 self.send_response(result) |
1855 self.send_header('Content-Type', 'text/html') | 1856 self.send_header('Content-Type', 'text/html') |
1856 self.send_header('Content-Length', len(raw_reply)) | 1857 self.send_header('Content-Length', len(raw_reply)) |
1857 self.end_headers() | 1858 self.end_headers() |
1858 self.wfile.write(raw_reply) | 1859 self.wfile.write(raw_reply) |
1859 return True; | 1860 return True; |
1860 | 1861 |
| 1862 def ChromiumSyncCreateSyncedBookmarksOpHandler(self): |
| 1863 test_name = "/chromiumsync/createsyncedbookmarks" |
| 1864 if not self._ShouldHandleRequest(test_name): |
| 1865 return False |
| 1866 result, raw_reply = self.server._sync_handler.HandleCreateSyncedBookmarks() |
| 1867 self.send_response(result) |
| 1868 self.send_header('Content-Type', 'text/html') |
| 1869 self.send_header('Content-Length', len(raw_reply)) |
| 1870 self.end_headers() |
| 1871 self.wfile.write(raw_reply) |
| 1872 return True; |
| 1873 |
1861 | 1874 |
1862 def MakeDataDir(): | 1875 def MakeDataDir(): |
1863 if options.data_dir: | 1876 if options.data_dir: |
1864 if not os.path.isdir(options.data_dir): | 1877 if not os.path.isdir(options.data_dir): |
1865 print 'specified data dir not found: ' + options.data_dir + ' exiting...' | 1878 print 'specified data dir not found: ' + options.data_dir + ' exiting...' |
1866 return None | 1879 return None |
1867 my_data_dir = options.data_dir | 1880 my_data_dir = options.data_dir |
1868 else: | 1881 else: |
1869 # Create the default path to our data dir, relative to the exe dir. | 1882 # Create the default path to our data dir, relative to the exe dir. |
1870 my_data_dir = os.path.dirname(sys.argv[0]) | 1883 my_data_dir = os.path.dirname(sys.argv[0]) |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2131 dest='host', | 2144 dest='host', |
2132 help='Hostname or IP upon which the server will ' | 2145 help='Hostname or IP upon which the server will ' |
2133 'listen. Client connections will also only be ' | 2146 'listen. Client connections will also only be ' |
2134 'allowed from this address.') | 2147 'allowed from this address.') |
2135 option_parser.add_option('', '--auth-token', dest='auth_token', | 2148 option_parser.add_option('', '--auth-token', dest='auth_token', |
2136 help='Specify the auth token which should be used' | 2149 help='Specify the auth token which should be used' |
2137 'in the authorization header for GData.') | 2150 'in the authorization header for GData.') |
2138 options, args = option_parser.parse_args() | 2151 options, args = option_parser.parse_args() |
2139 | 2152 |
2140 sys.exit(main(options, args)) | 2153 sys.exit(main(options, args)) |
OLD | NEW |