--- a/etwist/request.py Thu Mar 15 17:54:40 2012 +0100
+++ b/etwist/request.py Thu Mar 15 18:34:59 2012 +0100
@@ -33,16 +33,13 @@
class CubicWebTwistedRequestAdapter(CubicWebRequestBase):
def __init__(self, req, vreg, https):
self._twreq = req
- super(CubicWebTwistedRequestAdapter, self).__init__(vreg, https, req.args)
+ super(CubicWebTwistedRequestAdapter, self).__init__(
+ vreg, https, req.args, headers=req.received_headers)
for key, (name, stream) in req.files.iteritems():
if name is None:
self.form[key] = (name, stream)
else:
self.form[key] = (unicode(name, self.encoding), stream)
- # XXX can't we keep received_headers?
- self._headers_in = Headers()
- for k, v in req.received_headers.iteritems():
- self._headers_in.addRawHeader(k, v)
def http_method(self):
"""returns 'POST', 'GET', 'HEAD', etc."""
@@ -61,14 +58,6 @@
path = path.split('?', 1)[0]
return path
- def get_header(self, header, default=None, raw=True):
- """return the value associated with the given input header, raise
- KeyError if the header is not set
- """
- if raw:
- return self._headers_in.getRawHeaders(header, [default])[0]
- return self._headers_in.getHeader(header, default)
-
def _validate_cache(self):
"""raise a `DirectResponse` exception if a cached page along the way
exists and is still usable
@@ -95,21 +84,3 @@
raise DirectResponse(response)
# Expires header seems to be required by IE7
self.add_header('Expires', 'Sat, 01 Jan 2000 00:00:00 GMT')
-
- def header_accept_language(self):
- """returns an ordered list of preferred languages"""
- acceptedlangs = self.get_header('Accept-Language', raw=False) or {}
- for lang, _ in sorted(acceptedlangs.iteritems(), key=lambda x: x[1],
- reverse=True):
- lang = lang.split('-')[0]
- yield lang
-
- def header_if_modified_since(self):
- """If the HTTP header If-modified-since is set, return the equivalent
- date time value (GMT), else return None
- """
- mtime = self.get_header('If-modified-since', raw=False)
- if mtime:
- # :/ twisted is returned a localized time stamp
- return datetime.fromtimestamp(mtime) + GMTOFFSET
- return None