Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Unified Diff: net/tools/testserver/testserver.py

Issue 20279: Add a unit test for ERR_UNEXPECTED_SERVER_AUTH.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/url_request/url_request_http_job.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/testserver/testserver.py
===================================================================
--- net/tools/testserver/testserver.py (revision 9641)
+++ net/tools/testserver/testserver.py (working copy)
@@ -77,6 +77,7 @@
def __init__(self, request, client_address, socket_server):
self._connect_handlers = [
self.RedirectConnectHandler,
+ self.ServerAuthConnectHandler,
self.DefaultConnectResponseHandler]
self._get_handlers = [
self.KillHandler,
@@ -912,7 +913,22 @@
self.end_headers()
return True
+ def ServerAuthConnectHandler(self):
+ """Sends a 401 to the CONNECT request for www.server-auth.com. This
+ response doesn't make sense because the proxy server cannot request
+ server authentication."""
+ if (self.path.find("www.server-auth.com") < 0):
+ return False
+
+ challenge = 'Basic realm="WallyWorld"'
+
+ self.send_response(401) # unauthorized
+ self.send_header('WWW-Authenticate', challenge)
+ self.send_header('Connection', 'close')
+ self.end_headers()
+ return True
+
def DefaultConnectResponseHandler(self):
"""This is the catch-all response handler for CONNECT requests that aren't
handled by one of the special handlers above. Real Web servers respond
« no previous file with comments | « no previous file | net/url_request/url_request_http_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698