| OLD | NEW |
| 1 #!/usr/bin/python2.4 | 1 #!/usr/bin/python2.4 |
| 2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2008 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 server used for testing Chrome. | 6 """This is a simple HTTP 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 It defaults to living on localhost:8888. | 9 It defaults to living on localhost:8888. |
| 10 It can use https if you specify the flag --https=CERT where CERT is the path | 10 It can use https if you specify the flag --https=CERT where CERT is the path |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 return True | 562 return True |
| 563 | 563 |
| 564 def FileHandler(self): | 564 def FileHandler(self): |
| 565 """This handler sends the contents of the requested file. Wow, it's like | 565 """This handler sends the contents of the requested file. Wow, it's like |
| 566 a real webserver!""" | 566 a real webserver!""" |
| 567 | 567 |
| 568 prefix = self.server.file_root_url | 568 prefix = self.server.file_root_url |
| 569 if not self.path.startswith(prefix): | 569 if not self.path.startswith(prefix): |
| 570 return False | 570 return False |
| 571 | 571 |
| 572 # Consume a request body if present. | |
| 573 if self.command == 'POST': | |
| 574 self.rfile.read(int(self.headers.getheader('content-length'))) | |
| 575 | |
| 576 file = self.path[len(prefix):] | 572 file = self.path[len(prefix):] |
| 577 entries = file.split('/'); | 573 entries = file.split('/'); |
| 578 path = os.path.join(self.server.data_dir, *entries) | 574 path = os.path.join(self.server.data_dir, *entries) |
| 579 if os.path.isdir(path): | 575 if os.path.isdir(path): |
| 580 path = os.path.join(path, 'index.html') | 576 path = os.path.join(path, 'index.html') |
| 581 | 577 |
| 582 if not os.path.isfile(path): | 578 if not os.path.isfile(path): |
| 583 print "File not found " + file + " full path:" + path | 579 print "File not found " + file + " full path:" + path |
| 584 self.send_error(404) | 580 self.send_error(404) |
| 585 return True | 581 return True |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 help='Directory from which to read the files') | 1103 help='Directory from which to read the files') |
| 1108 option_parser.add_option('', '--https', dest='cert', | 1104 option_parser.add_option('', '--https', dest='cert', |
| 1109 help='Specify that https should be used, specify ' | 1105 help='Specify that https should be used, specify ' |
| 1110 'the path to the cert containing the private key ' | 1106 'the path to the cert containing the private key ' |
| 1111 'the server should use') | 1107 'the server should use') |
| 1112 option_parser.add_option('', '--file-root-url', default='/files/', | 1108 option_parser.add_option('', '--file-root-url', default='/files/', |
| 1113 help='Specify a root URL for files served.') | 1109 help='Specify a root URL for files served.') |
| 1114 options, args = option_parser.parse_args() | 1110 options, args = option_parser.parse_args() |
| 1115 | 1111 |
| 1116 sys.exit(main(options, args)) | 1112 sys.exit(main(options, args)) |
| OLD | NEW |