| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 return True | 70 return True |
| 71 except tlslite.api.TLSError, error: | 71 except tlslite.api.TLSError, error: |
| 72 print "Handshake failure:", str(error) | 72 print "Handshake failure:", str(error) |
| 73 return False | 73 return False |
| 74 | 74 |
| 75 class TestPageHandler(BaseHTTPServer.BaseHTTPRequestHandler): | 75 class TestPageHandler(BaseHTTPServer.BaseHTTPRequestHandler): |
| 76 | 76 |
| 77 def __init__(self, request, client_address, socket_server): | 77 def __init__(self, request, client_address, socket_server): |
| 78 self._connect_handlers = [ | 78 self._connect_handlers = [ |
| 79 self.RedirectConnectHandler, | 79 self.RedirectConnectHandler, |
| 80 self.ServerAuthConnectHandler, |
| 80 self.DefaultConnectResponseHandler] | 81 self.DefaultConnectResponseHandler] |
| 81 self._get_handlers = [ | 82 self._get_handlers = [ |
| 82 self.KillHandler, | 83 self.KillHandler, |
| 83 self.NoCacheMaxAgeTimeHandler, | 84 self.NoCacheMaxAgeTimeHandler, |
| 84 self.NoCacheTimeHandler, | 85 self.NoCacheTimeHandler, |
| 85 self.CacheTimeHandler, | 86 self.CacheTimeHandler, |
| 86 self.CacheExpiresHandler, | 87 self.CacheExpiresHandler, |
| 87 self.CacheProxyRevalidateHandler, | 88 self.CacheProxyRevalidateHandler, |
| 88 self.CachePrivateHandler, | 89 self.CachePrivateHandler, |
| 89 self.CachePublicHandler, | 90 self.CachePublicHandler, |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 return False | 906 return False |
| 906 | 907 |
| 907 dest = "http://www.destination.com/foo.js" | 908 dest = "http://www.destination.com/foo.js" |
| 908 | 909 |
| 909 self.send_response(302) # moved temporarily | 910 self.send_response(302) # moved temporarily |
| 910 self.send_header('Location', dest) | 911 self.send_header('Location', dest) |
| 911 self.send_header('Connection', 'close') | 912 self.send_header('Connection', 'close') |
| 912 self.end_headers() | 913 self.end_headers() |
| 913 return True | 914 return True |
| 914 | 915 |
| 916 def ServerAuthConnectHandler(self): |
| 917 """Sends a 401 to the CONNECT request for www.server-auth.com. This |
| 918 response doesn't make sense because the proxy server cannot request |
| 919 server authentication.""" |
| 920 |
| 921 if (self.path.find("www.server-auth.com") < 0): |
| 922 return False |
| 923 |
| 924 challenge = 'Basic realm="WallyWorld"' |
| 925 |
| 926 self.send_response(401) # unauthorized |
| 927 self.send_header('WWW-Authenticate', challenge) |
| 928 self.send_header('Connection', 'close') |
| 929 self.end_headers() |
| 930 return True |
| 915 | 931 |
| 916 def DefaultConnectResponseHandler(self): | 932 def DefaultConnectResponseHandler(self): |
| 917 """This is the catch-all response handler for CONNECT requests that aren't | 933 """This is the catch-all response handler for CONNECT requests that aren't |
| 918 handled by one of the special handlers above. Real Web servers respond | 934 handled by one of the special handlers above. Real Web servers respond |
| 919 with 400 to CONNECT requests.""" | 935 with 400 to CONNECT requests.""" |
| 920 | 936 |
| 921 contents = "Your client has issued a malformed or illegal request." | 937 contents = "Your client has issued a malformed or illegal request." |
| 922 self.send_response(400) # bad request | 938 self.send_response(400) # bad request |
| 923 self.send_header('Content-type', 'text/html') | 939 self.send_header('Content-type', 'text/html') |
| 924 self.send_header("Content-Length", len(contents)) | 940 self.send_header("Content-Length", len(contents)) |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 option_parser.add_option('', '--data-dir', dest='data_dir', | 1063 option_parser.add_option('', '--data-dir', dest='data_dir', |
| 1048 help='Directory from which to read the files') | 1064 help='Directory from which to read the files') |
| 1049 option_parser.add_option('', '--https', dest='cert', | 1065 option_parser.add_option('', '--https', dest='cert', |
| 1050 help='Specify that https should be used, specify ' | 1066 help='Specify that https should be used, specify ' |
| 1051 'the path to the cert containing the private key ' | 1067 'the path to the cert containing the private key ' |
| 1052 'the server should use') | 1068 'the server should use') |
| 1053 options, args = option_parser.parse_args() | 1069 options, args = option_parser.parse_args() |
| 1054 | 1070 |
| 1055 sys.exit(main(options, args)) | 1071 sys.exit(main(options, args)) |
| 1056 | 1072 |
| OLD | NEW |