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 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1553 | 1553 |
1554 if range_response: | 1554 if range_response: |
1555 self.send_response(206) | 1555 self.send_response(206) |
1556 self.send_header('Content-Range', | 1556 self.send_header('Content-Range', |
1557 'bytes %d-%d/%d' % (first_byte, last_byte, size)) | 1557 'bytes %d-%d/%d' % (first_byte, last_byte, size)) |
1558 else: | 1558 else: |
1559 self.send_response(200) | 1559 self.send_response(200) |
1560 self.send_header('Content-Type', 'application/octet-stream') | 1560 self.send_header('Content-Type', 'application/octet-stream') |
1561 self.send_header('Content-Length', last_byte - first_byte + 1) | 1561 self.send_header('Content-Length', last_byte - first_byte + 1) |
1562 if send_verifiers: | 1562 if send_verifiers: |
1563 self.send_header('Etag', '"XYZZY"') | 1563 # If fail_precondition is non-zero, then the ETag for each request will be |
| 1564 # different. |
| 1565 etag = "%s%d" % (token, fail_precondition) |
| 1566 self.send_header('ETag', etag) |
1564 self.send_header('Last-Modified', 'Tue, 19 Feb 2013 14:32 EST') | 1567 self.send_header('Last-Modified', 'Tue, 19 Feb 2013 14:32 EST') |
1565 self.end_headers() | 1568 self.end_headers() |
1566 | 1569 |
1567 if hold_for_signal: | 1570 if hold_for_signal: |
1568 # TODO(rdsmith/phajdan.jr): http://crbug.com/169519: Without writing | 1571 # TODO(rdsmith/phajdan.jr): http://crbug.com/169519: Without writing |
1569 # a single byte, the self.server.handle_request() below hangs | 1572 # a single byte, the self.server.handle_request() below hangs |
1570 # without processing new incoming requests. | 1573 # without processing new incoming requests. |
1571 self.wfile.write(DataForRange(first_byte, first_byte + 1)) | 1574 self.wfile.write(DataForRange(first_byte, first_byte + 1)) |
1572 first_byte = first_byte + 1 | 1575 first_byte = first_byte + 1 |
1573 # handle requests until one of them clears this flag. | 1576 # handle requests until one of them clears this flag. |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2097 '"aes128", "3des", "rc4". If omitted, all ' | 2100 '"aes128", "3des", "rc4". If omitted, all ' |
2098 'algorithms will be used. This option may ' | 2101 'algorithms will be used. This option may ' |
2099 'appear multiple times, indicating ' | 2102 'appear multiple times, indicating ' |
2100 'multiple algorithms should be enabled.'); | 2103 'multiple algorithms should be enabled.'); |
2101 self.option_parser.add_option('--file-root-url', default='/files/', | 2104 self.option_parser.add_option('--file-root-url', default='/files/', |
2102 help='Specify a root URL for files served.') | 2105 help='Specify a root URL for files served.') |
2103 | 2106 |
2104 | 2107 |
2105 if __name__ == '__main__': | 2108 if __name__ == '__main__': |
2106 sys.exit(ServerRunner().main()) | 2109 sys.exit(ServerRunner().main()) |
OLD | NEW |