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

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

Issue 218363002: Docs: Use ETags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 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 | « chrome/common/extensions/docs/server2/render_servlet_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
'''
« no previous file with comments | « chrome/common/extensions/docs/server2/render_servlet_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698