| 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
|
|
|