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

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

Issue 612533002: Add /cross-site/ request handler to testserver.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/testserver/testserver.py
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py
index d020ca3a86fa47578a3005f85f59534a16fe9602..77399023f4168504ec35a2395997181de28b68a8 100755
--- a/net/tools/testserver/testserver.py
+++ b/net/tools/testserver/testserver.py
@@ -331,6 +331,7 @@ class TestPageHandler(testserver_base.BasePageHandler):
self.ContentTypeHandler,
self.NoContentHandler,
self.ServerRedirectHandler,
+ self.CrossSiteRedirectHandler,
self.ClientRedirectHandler,
self.GetSSLSessionCacheHandler,
self.SSLManySmallRecords,
@@ -1418,6 +1419,36 @@ class TestPageHandler(testserver_base.BasePageHandler):
return True
+ def CrossSiteRedirectHandler(self):
+ """Sends a server redirect to the given site. The syntax is
+ '/cross-site/hostname/...' to redirect to //hostname/...
+ It is used to navigate between different Sites, causing
+ cross-site/cross-process navigations in the browser."""
+
+ test_name = "/cross-site"
+ if not self._ShouldHandleRequest(test_name):
+ print "CSRH: not handling request for " + test_name
+ return False
+
+ params = urllib.unquote(self.path[(len(test_name) + 1):])
+ slash = params.find('/')
+ if slash < 0:
+ self.sendRedirectHelp(test_name)
+ return True
+
+ host = params[:slash]
+ path = params[(slash+1):]
+ dest = "//%s:%s/%s" % (host, str(self.server.server_port), path)
+
+ self.send_response(301) # moved permanently
+ self.send_header('Location', dest)
+ self.send_header('Content-Type', 'text/html')
+ self.end_headers()
+ self.wfile.write('<html><head>')
+ self.wfile.write('</head><body>Redirecting to %s</body></html>' % dest)
+
+ return True
+
def ClientRedirectHandler(self):
"""Sends a client redirect to the given URL. The syntax is
'/client-redirect?http://foo.bar/asdf' to redirect to
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698