OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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/TCP/UDP/BASIC_AUTH_PROXY/WEBSOCKET server used for | 6 """This is a simple HTTP/FTP/TCP/UDP/BASIC_AUTH_PROXY/WEBSOCKET server used for |
7 testing Chrome. | 7 testing 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 self.AuthDigestHandler, | 328 self.AuthDigestHandler, |
329 self.SlowServerHandler, | 329 self.SlowServerHandler, |
330 self.ChunkedServerHandler, | 330 self.ChunkedServerHandler, |
331 self.ContentTypeHandler, | 331 self.ContentTypeHandler, |
332 self.NoContentHandler, | 332 self.NoContentHandler, |
333 self.ServerRedirectHandler, | 333 self.ServerRedirectHandler, |
334 self.ClientRedirectHandler, | 334 self.ClientRedirectHandler, |
335 self.GetSSLSessionCacheHandler, | 335 self.GetSSLSessionCacheHandler, |
336 self.SSLManySmallRecords, | 336 self.SSLManySmallRecords, |
337 self.GetChannelID, | 337 self.GetChannelID, |
| 338 self.ClientCipherListHandler, |
338 self.CloseSocketHandler, | 339 self.CloseSocketHandler, |
339 self.RangeResetHandler, | 340 self.RangeResetHandler, |
340 self.DefaultResponseHandler] | 341 self.DefaultResponseHandler] |
341 post_handlers = [ | 342 post_handlers = [ |
342 self.EchoTitleHandler, | 343 self.EchoTitleHandler, |
343 self.EchoHandler, | 344 self.EchoHandler, |
344 self.PostOnlyFileHandler, | 345 self.PostOnlyFileHandler, |
345 self.EchoMultipartPostHandler] + get_handlers | 346 self.EchoMultipartPostHandler] + get_handlers |
346 put_handlers = [ | 347 put_handlers = [ |
347 self.EchoTitleHandler, | 348 self.EchoTitleHandler, |
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1485 if not self._ShouldHandleRequest('/channel-id'): | 1486 if not self._ShouldHandleRequest('/channel-id'): |
1486 return False | 1487 return False |
1487 | 1488 |
1488 self.send_response(200) | 1489 self.send_response(200) |
1489 self.send_header('Content-Type', 'text/plain') | 1490 self.send_header('Content-Type', 'text/plain') |
1490 self.end_headers() | 1491 self.end_headers() |
1491 channel_id = bytes(self.server.tlsConnection.channel_id) | 1492 channel_id = bytes(self.server.tlsConnection.channel_id) |
1492 self.wfile.write(hashlib.sha256(channel_id).digest().encode('base64')) | 1493 self.wfile.write(hashlib.sha256(channel_id).digest().encode('base64')) |
1493 return True | 1494 return True |
1494 | 1495 |
| 1496 def ClientCipherListHandler(self): |
| 1497 """Send a reply containing the cipher suite list that the client |
| 1498 provided. Each cipher suite value is serialized in decimal, followed by a |
| 1499 newline.""" |
| 1500 |
| 1501 if not self._ShouldHandleRequest('/client-cipher-list'): |
| 1502 return False |
| 1503 |
| 1504 self.send_response(200) |
| 1505 self.send_header('Content-Type', 'text/plain') |
| 1506 self.end_headers() |
| 1507 |
| 1508 for cipher_suite in self.server.tlsConnection.clientHello.cipher_suites: |
| 1509 self.wfile.write(str(cipher_suite)) |
| 1510 self.wfile.write('\n') |
| 1511 return True |
| 1512 |
1495 def CloseSocketHandler(self): | 1513 def CloseSocketHandler(self): |
1496 """Closes the socket without sending anything.""" | 1514 """Closes the socket without sending anything.""" |
1497 | 1515 |
1498 if not self._ShouldHandleRequest('/close-socket'): | 1516 if not self._ShouldHandleRequest('/close-socket'): |
1499 return False | 1517 return False |
1500 | 1518 |
1501 self.wfile.close() | 1519 self.wfile.close() |
1502 return True | 1520 return True |
1503 | 1521 |
1504 def RangeResetHandler(self): | 1522 def RangeResetHandler(self): |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2218 self.option_parser.add_option('--file-root-url', default='/files/', | 2236 self.option_parser.add_option('--file-root-url', default='/files/', |
2219 help='Specify a root URL for files served.') | 2237 help='Specify a root URL for files served.') |
2220 # TODO(ricea): Generalize this to support basic auth for HTTP too. | 2238 # TODO(ricea): Generalize this to support basic auth for HTTP too. |
2221 self.option_parser.add_option('--ws-basic-auth', action='store_true', | 2239 self.option_parser.add_option('--ws-basic-auth', action='store_true', |
2222 dest='ws_basic_auth', | 2240 dest='ws_basic_auth', |
2223 help='Enable basic-auth for WebSocket') | 2241 help='Enable basic-auth for WebSocket') |
2224 | 2242 |
2225 | 2243 |
2226 if __name__ == '__main__': | 2244 if __name__ == '__main__': |
2227 sys.exit(ServerRunner().main()) | 2245 sys.exit(ServerRunner().main()) |
OLD | NEW |