summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-05-08 11:31:36 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-05-08 11:31:36 +0000
commit38a6c48878c4318fac404e6ee2454d78b26c098b (patch)
treed26171dae476dcc27b0ca8c909be7d4c2863c341
parent155ab07a5d40f5e0a426423cb8df3868a37a02f8 (diff)
Fixed a silly function flow bug in [10711].
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10712 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/http/__init__.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/django/http/__init__.py b/django/http/__init__.py
index 92c38c0ad6..683212fcd4 100644
--- a/django/http/__init__.py
+++ b/django/http/__init__.py
@@ -304,16 +304,17 @@ class HttpResponse(object):
def _convert_to_ascii(self, *values):
"""Converts all values to ascii strings."""
for value in values:
- if '\n' in value or '\r' in value:
- raise BadHeaderError("Header values can't contain newlines (got %r)" % (value))
if isinstance(value, unicode):
try:
- yield value.encode('us-ascii')
+ value = value.encode('us-ascii')
except UnicodeError, e:
e.reason += ', HTTP response headers must be in US-ASCII format'
raise
else:
- yield str(value)
+ value = str(value)
+ if '\n' in value or '\r' in value:
+ raise BadHeaderError("Header values can't contain newlines (got %r)" % (value))
+ yield value
def __setitem__(self, header, value):
header, value = self._convert_to_ascii(header, value)