OLD | NEW |
1 #!/usr/bin/python2.4 | 1 #!/usr/bin/python2.4 |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 By default, it listens on an ephemeral port and sends the port number back to | 9 By default, it listens on an ephemeral port and sends the port number back to |
10 the originating process over a pipe. The originating process can specify an | 10 the originating process over a pipe. The originating process can specify an |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 self.DownloadFinishHandler, | 279 self.DownloadFinishHandler, |
280 self.EchoHeader, | 280 self.EchoHeader, |
281 self.EchoHeaderOverride, | 281 self.EchoHeaderOverride, |
282 self.EchoAllHandler, | 282 self.EchoAllHandler, |
283 self.FileHandler, | 283 self.FileHandler, |
284 self.SetCookieHandler, | 284 self.SetCookieHandler, |
285 self.AuthBasicHandler, | 285 self.AuthBasicHandler, |
286 self.AuthDigestHandler, | 286 self.AuthDigestHandler, |
287 self.SlowServerHandler, | 287 self.SlowServerHandler, |
288 self.ContentTypeHandler, | 288 self.ContentTypeHandler, |
| 289 self.NoContentHandler, |
289 self.ServerRedirectHandler, | 290 self.ServerRedirectHandler, |
290 self.ClientRedirectHandler, | 291 self.ClientRedirectHandler, |
291 self.MultipartHandler, | 292 self.MultipartHandler, |
292 self.DefaultResponseHandler] | 293 self.DefaultResponseHandler] |
293 post_handlers = [ | 294 post_handlers = [ |
294 self.EchoTitleHandler, | 295 self.EchoTitleHandler, |
295 self.EchoAllHandler, | 296 self.EchoAllHandler, |
296 self.EchoHandler, | 297 self.EchoHandler, |
297 self.DeviceManagementHandler] + get_handlers | 298 self.DeviceManagementHandler] + get_handlers |
298 put_handlers = [ | 299 put_handlers = [ |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 query_char = self.path.find('?') | 1064 query_char = self.path.find('?') |
1064 content_type = self.path[query_char + 1:].strip() | 1065 content_type = self.path[query_char + 1:].strip() |
1065 if not content_type: | 1066 if not content_type: |
1066 content_type = 'text/html' | 1067 content_type = 'text/html' |
1067 self.send_response(200) | 1068 self.send_response(200) |
1068 self.send_header('Content-Type', content_type) | 1069 self.send_header('Content-Type', content_type) |
1069 self.end_headers() | 1070 self.end_headers() |
1070 self.wfile.write("<html>\n<body>\n<p>HTML text</p>\n</body>\n</html>\n"); | 1071 self.wfile.write("<html>\n<body>\n<p>HTML text</p>\n</body>\n</html>\n"); |
1071 return True | 1072 return True |
1072 | 1073 |
| 1074 def NoContentHandler(self): |
| 1075 """Returns a 204 No Content response.""" |
| 1076 if not self._ShouldHandleRequest("/nocontent"): |
| 1077 return False |
| 1078 self.send_response(204) |
| 1079 self.end_headers() |
| 1080 return True |
| 1081 |
1073 def ServerRedirectHandler(self): | 1082 def ServerRedirectHandler(self): |
1074 """Sends a server redirect to the given URL. The syntax is | 1083 """Sends a server redirect to the given URL. The syntax is |
1075 '/server-redirect?http://foo.bar/asdf' to redirect to | 1084 '/server-redirect?http://foo.bar/asdf' to redirect to |
1076 'http://foo.bar/asdf'""" | 1085 'http://foo.bar/asdf'""" |
1077 | 1086 |
1078 test_name = "/server-redirect" | 1087 test_name = "/server-redirect" |
1079 if not self._ShouldHandleRequest(test_name): | 1088 if not self._ShouldHandleRequest(test_name): |
1080 return False | 1089 return False |
1081 | 1090 |
1082 query_char = self.path.find('?') | 1091 query_char = self.path.find('?') |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 option_parser.add_option('', '--policy-cert-chain', action='append', | 1465 option_parser.add_option('', '--policy-cert-chain', action='append', |
1457 help='Specify a path to a certificate file to sign ' | 1466 help='Specify a path to a certificate file to sign ' |
1458 'policy responses. This option may be used ' | 1467 'policy responses. This option may be used ' |
1459 'multiple times to define a certificate chain. ' | 1468 'multiple times to define a certificate chain. ' |
1460 'The first element will be used for signing, ' | 1469 'The first element will be used for signing, ' |
1461 'the last element should be the root ' | 1470 'the last element should be the root ' |
1462 'certificate.') | 1471 'certificate.') |
1463 options, args = option_parser.parse_args() | 1472 options, args = option_parser.parse_args() |
1464 | 1473 |
1465 sys.exit(main(options, args)) | 1474 sys.exit(main(options, args)) |
OLD | NEW |