| 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 f7c14e7b84baa0d92d0da29f4f5f0cd68c138b91..7672ca597e2140c4d720d83d01ce4800873bc6e4 100644
|
| --- a/chrome/common/extensions/docs/server2/servlet.py
|
| +++ b/chrome/common/extensions/docs/server2/servlet.py
|
| @@ -2,13 +2,34 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
|
|
| +
|
| +class RequestHeaders(object):
|
| + '''A custom dictionary impementation for headers which ignores the case
|
| + of requests, since different HTTP libraries seem to mangle them.
|
| + '''
|
| + def __init__(self, dict_):
|
| + if isinstance(dict_, RequestHeaders):
|
| + self._dict = dict_
|
| + else:
|
| + self._dict = dict((k.lower(), v) for k, v in dict_.iteritems())
|
| +
|
| + def get(self, key, default=None):
|
| + return self._dict.get(key.lower(), default)
|
| +
|
| + def __repr__(self):
|
| + return repr(self._dict)
|
| +
|
| + def __str__(self):
|
| + return repr(self._dict)
|
| +
|
| +
|
| class Request(object):
|
| '''Request data.
|
| '''
|
| def __init__(self, path, host, headers):
|
| self.path = path.lstrip('/')
|
| self.host = host.rstrip('/')
|
| - self.headers = headers
|
| + self.headers = RequestHeaders(headers)
|
|
|
| @staticmethod
|
| def ForTest(path, host='http://developer.chrome.com', headers=None):
|
| @@ -77,6 +98,10 @@ class Response(object):
|
| return Response(content=content, headers=headers, status=404)
|
|
|
| @staticmethod
|
| + def NotModified(content, headers=None):
|
| + return Response(content=content, headers=headers, status=304)
|
| +
|
| + @staticmethod
|
| def InternalError(content, headers=None):
|
| '''Returns an internal error (500) response.
|
| '''
|
|
|