| 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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 self.send_header('Cache-Control', 'max-age=60, proxy-revalidate') | 464 self.send_header('Cache-Control', 'max-age=60, proxy-revalidate') |
| 465 self.end_headers() | 465 self.end_headers() |
| 466 | 466 |
| 467 self.wfile.write('<html><head><title>%s</title></head></html>' % | 467 self.wfile.write('<html><head><title>%s</title></head></html>' % |
| 468 time.time()) | 468 time.time()) |
| 469 | 469 |
| 470 return True | 470 return True |
| 471 | 471 |
| 472 def CachePrivateHandler(self): | 472 def CachePrivateHandler(self): |
| 473 """This request handler yields a page with the title set to the current | 473 """This request handler yields a page with the title set to the current |
| 474 system time, and allows caching for 5 seconds.""" | 474 system time, and allows caching for 3 seconds.""" |
| 475 | 475 |
| 476 if not self._ShouldHandleRequest("/cache/private"): | 476 if not self._ShouldHandleRequest("/cache/private"): |
| 477 return False | 477 return False |
| 478 | 478 |
| 479 self.send_response(200) | 479 self.send_response(200) |
| 480 self.send_header('Content-Type', 'text/html') | 480 self.send_header('Content-Type', 'text/html') |
| 481 self.send_header('Cache-Control', 'max-age=3, private') | 481 self.send_header('Cache-Control', 'max-age=3, private') |
| 482 self.end_headers() | 482 self.end_headers() |
| 483 | 483 |
| 484 self.wfile.write('<html><head><title>%s</title></head></html>' % | 484 self.wfile.write('<html><head><title>%s</title></head></html>' % |
| 485 time.time()) | 485 time.time()) |
| 486 | 486 |
| 487 return True | 487 return True |
| 488 | 488 |
| 489 def CachePublicHandler(self): | 489 def CachePublicHandler(self): |
| 490 """This request handler yields a page with the title set to the current | 490 """This request handler yields a page with the title set to the current |
| 491 system time, and allows caching for 5 seconds.""" | 491 system time, and allows caching for 3 seconds.""" |
| 492 | 492 |
| 493 if not self._ShouldHandleRequest("/cache/public"): | 493 if not self._ShouldHandleRequest("/cache/public"): |
| 494 return False | 494 return False |
| 495 | 495 |
| 496 self.send_response(200) | 496 self.send_response(200) |
| 497 self.send_header('Content-Type', 'text/html') | 497 self.send_header('Content-Type', 'text/html') |
| 498 self.send_header('Cache-Control', 'max-age=3, public') | 498 self.send_header('Cache-Control', 'max-age=3, public') |
| 499 self.end_headers() | 499 self.end_headers() |
| 500 | 500 |
| 501 self.wfile.write('<html><head><title>%s</title></head></html>' % | 501 self.wfile.write('<html><head><title>%s</title></head></html>' % |
| (...skipping 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2281 'alert immediately after the handshake.') | 2281 'alert immediately after the handshake.') |
| 2282 self.option_parser.add_option('--no-anonymous-ftp-user', | 2282 self.option_parser.add_option('--no-anonymous-ftp-user', |
| 2283 dest='no_anonymous_ftp_user', | 2283 dest='no_anonymous_ftp_user', |
| 2284 default=False, action='store_true', | 2284 default=False, action='store_true', |
| 2285 help='If set, the FTP server will not create ' | 2285 help='If set, the FTP server will not create ' |
| 2286 'an anonymous user.') | 2286 'an anonymous user.') |
| 2287 | 2287 |
| 2288 | 2288 |
| 2289 if __name__ == '__main__': | 2289 if __name__ == '__main__': |
| 2290 sys.exit(ServerRunner().main()) | 2290 sys.exit(ServerRunner().main()) |
| OLD | NEW |