summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2007-09-14 22:33:56 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2007-09-14 22:33:56 +0000
commitca9388cdaf905e12560c751ca55f8237303e4494 (patch)
tree9d83a5a092579c27167bc2be5d2ae1f7f7b9657d /django
parent71796410ba8e292a39610a4435f7693ca37b4289 (diff)
Added more dict-like methods to HttpResponse as part of the response.headers -> response._headers move, and fixed a few direct uses of response.headers in Django itself. Thanks to PhiR for tracking down and slaying these bugs.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6235 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/core/handlers/modpython.py4
-rw-r--r--django/core/handlers/wsgi.py2
-rw-r--r--django/http/__init__.py6
-rw-r--r--django/middleware/gzip.py2
4 files changed, 10 insertions, 4 deletions
diff --git a/django/core/handlers/modpython.py b/django/core/handlers/modpython.py
index 7c4bbb3082..f98566be96 100644
--- a/django/core/handlers/modpython.py
+++ b/django/core/handlers/modpython.py
@@ -159,8 +159,8 @@ class ModPythonHandler(BaseHandler):
# Convert our custom HttpResponse object back into the mod_python req.
req.content_type = response['Content-Type']
- for key, value in response.headers.items():
- if key != 'Content-Type':
+ for key, value in response.items():
+ if key != 'content-type':
req.headers_out[str(key)] = str(value)
for c in response.cookies.values():
req.headers_out.add('Set-Cookie', c.output(header=''))
diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py
index 99d400d1bb..6fe24f5d13 100644
--- a/django/core/handlers/wsgi.py
+++ b/django/core/handlers/wsgi.py
@@ -208,7 +208,7 @@ class WSGIHandler(BaseHandler):
except KeyError:
status_text = 'UNKNOWN STATUS CODE'
status = '%s %s' % (response.status_code, status_text)
- response_headers = [(str(k), str(v)) for k, v in response.headers.items()]
+ response_headers = [(str(k), str(v)) for k, v in response.items()]
for c in response.cookies.values():
response_headers.append(('Set-Cookie', str(c.output(header=''))))
start_response(status, response_headers)
diff --git a/django/http/__init__.py b/django/http/__init__.py
index 1de0ffb1df..1b80237290 100644
--- a/django/http/__init__.py
+++ b/django/http/__init__.py
@@ -274,6 +274,12 @@ class HttpResponse(object):
return self._headers.has_key(header.lower())
__contains__ = has_header
+
+ def items(self):
+ return self._headers.items()
+
+ def get(self, header, alternate):
+ return self._headers.get(header, alternate)
def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=None):
self.cookies[key] = value
diff --git a/django/middleware/gzip.py b/django/middleware/gzip.py
index 9b2a5f3d22..7fd0d82419 100644
--- a/django/middleware/gzip.py
+++ b/django/middleware/gzip.py
@@ -20,7 +20,7 @@ class GZipMiddleware(object):
# Avoid gzipping if we've already got a content-encoding or if the
# content-type is Javascript (silly IE...)
- is_js = "javascript" in response.headers.get('Content-Type', '').lower()
+ is_js = "javascript" in response.get('Content-Type', '').lower()
if response.has_header('Content-Encoding') or is_js:
return response