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

Unified Diff: chrome/common/extensions/docs/server2/servlet.py

Issue 15009006: Docserver: refactor Servlet, ObjectStore, and ServerInstance architecture to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cduvall, redirect fix Created 7 years, 7 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
Index: chrome/common/extensions/docs/server2/servlet.py
diff --git a/chrome/common/extensions/docs/server2/servlet.py b/chrome/common/extensions/docs/server2/servlet.py
index 6c048a03f984b67b374ca74be4d9df8fa2f6d62d..9618bbddb1fe0ffdaf3329a748063f515046d99f 100644
--- a/chrome/common/extensions/docs/server2/servlet.py
+++ b/chrome/common/extensions/docs/server2/servlet.py
@@ -5,10 +5,22 @@
class Request(object):
'''Request data.
'''
- def __init__(self, path, headers):
- self.path = path
+ def __init__(self, path, host, headers):
+ self.path = path.lstrip('/')
+ self.host = host.rstrip('/')
self.headers = headers
+ @staticmethod
+ def ForTest(path, url='http://localhost', headers=None):
+ return Request(path, url, headers or {})
+
+ def __repr__(self):
+ return 'Request(path=%s, host=%s, headers=%s entries)' % (
+ self.path, self.host, len(self.headers.keys()))
+
+ def __str__(self):
+ return repr(self)
+
class _ContentBuilder(object):
'''Builds the response content.
'''
@@ -55,8 +67,6 @@ class Response(object):
def Redirect(url, permanent=False):
'''Returns a redirect (301 or 302) response.
'''
- if not url.startswith('/'):
- url = '/%s' % url
status = 301 if permanent else 302
return Response(headers={'Location': url}, status=status)
@@ -91,9 +101,12 @@ class Response(object):
self.status = status
def __repr__(self):
- return '{content: %s bytes, status: %s, headers: %s entries}' % (
+ return 'Response(content=%s bytes, status=%s, headers=%s entries)' % (
len(self.content), self.status, len(self.headers.keys()))
+ def __str__(self):
+ return repr(self)
+
class Servlet(object):
def __init__(self, request):
self._request = request

Powered by Google App Engine
This is Rietveld 408576698