| 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 |
| 572 file = self.path[len(prefix):] | 576 file = self.path[len(prefix):] |
| 573 entries = file.split('/'); | 577 entries = file.split('/'); |
| 574 path = os.path.join(self.server.data_dir, *entries) | 578 path = os.path.join(self.server.data_dir, *entries) |
| 575 if os.path.isdir(path): | 579 if os.path.isdir(path): |
| 576 path = os.path.join(path, 'index.html') | 580 path = os.path.join(path, 'index.html') |
| 577 | 581 |
| 578 if not os.path.isfile(path): | 582 if not os.path.isfile(path): |
| 579 print "File not found " + file + " full path:" + path | 583 print "File not found " + file + " full path:" + path |
| 580 self.send_error(404) | 584 self.send_error(404) |
| 581 return True | 585 return True |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 help='Directory from which to read the files') | 1107 help='Directory from which to read the files') |
| 1104 option_parser.add_option('', '--https', dest='cert', | 1108 option_parser.add_option('', '--https', dest='cert', |
| 1105 help='Specify that https should be used, specify ' | 1109 help='Specify that https should be used, specify ' |
| 1106 'the path to the cert containing the private key ' | 1110 'the path to the cert containing the private key ' |
| 1107 'the server should use') | 1111 'the server should use') |
| 1108 option_parser.add_option('', '--file-root-url', default='/files/', | 1112 option_parser.add_option('', '--file-root-url', default='/files/', |
| 1109 help='Specify a root URL for files served.') | 1113 help='Specify a root URL for files served.') |
| 1110 options, args = option_parser.parse_args() | 1114 options, args = option_parser.parse_args() |
| 1111 | 1115 |
| 1112 sys.exit(main(options, args)) | 1116 sys.exit(main(options, args)) |
| OLD | NEW |