| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 143 |
| 144 def GetMIMETypeFromName(self, file_name): | 144 def GetMIMETypeFromName(self, file_name): |
| 145 """Returns the mime type for the specified file_name. So far it only looks | 145 """Returns the mime type for the specified file_name. So far it only looks |
| 146 at the file extension.""" | 146 at the file extension.""" |
| 147 | 147 |
| 148 (shortname, extension) = os.path.splitext(file_name) | 148 (shortname, extension) = os.path.splitext(file_name) |
| 149 if len(extension) == 0: | 149 if len(extension) == 0: |
| 150 # no extension. | 150 # no extension. |
| 151 return self._default_mime_type | 151 return self._default_mime_type |
| 152 | 152 |
| 153 return self._mime_types.get(extension, self._default_mime_type) | 153 # extension starts with a dot, so we need to remove it |
| 154 return self._mime_types.get(extension[1:], self._default_mime_type) |
| 154 | 155 |
| 155 def KillHandler(self): | 156 def KillHandler(self): |
| 156 """This request handler kills the server, for use when we're done" | 157 """This request handler kills the server, for use when we're done" |
| 157 with the a particular test.""" | 158 with the a particular test.""" |
| 158 | 159 |
| 159 if (self.path.find("kill") < 0): | 160 if (self.path.find("kill") < 0): |
| 160 return False | 161 return False |
| 161 | 162 |
| 162 self.send_response(200) | 163 self.send_response(200) |
| 163 self.send_header('Content-type', 'text/html') | 164 self.send_header('Content-type', 'text/html') |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 help='Directory from which to read the files') | 1104 help='Directory from which to read the files') |
| 1104 option_parser.add_option('', '--https', dest='cert', | 1105 option_parser.add_option('', '--https', dest='cert', |
| 1105 help='Specify that https should be used, specify ' | 1106 help='Specify that https should be used, specify ' |
| 1106 'the path to the cert containing the private key ' | 1107 'the path to the cert containing the private key ' |
| 1107 'the server should use') | 1108 'the server should use') |
| 1108 option_parser.add_option('', '--file-root-url', default='/files/', | 1109 option_parser.add_option('', '--file-root-url', default='/files/', |
| 1109 help='Specify a root URL for files served.') | 1110 help='Specify a root URL for files served.') |
| 1110 options, args = option_parser.parse_args() | 1111 options, args = option_parser.parse_args() |
| 1111 | 1112 |
| 1112 sys.exit(main(options, args)) | 1113 sys.exit(main(options, args)) |
| OLD | NEW |