summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hellkamp <marc@gsites.de>2012-08-23 18:39:42 +0200
committerMarcel Hellkamp <marc@gsites.de>2012-08-30 01:42:08 +0200
commit9d2f04a3c0aca3ee4c5aa363e0a6a770e10f71a6 (patch)
tree42c41d934bd40c5fe730d08609a76892b9c07137
parent49c65935f554c708797300a57ef26c1b0d621c29 (diff)
downloadbottle-9d2f04a3c0aca3ee4c5aa363e0a6a770e10f71a6.tar.gz
Fix: Bottle no longer changes the Content-Length response header if it was set by the application. (fix #311)
-rw-r--r--bottle.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/bottle.py b/bottle.py
index bdafbcf..70782d4 100644
--- a/bottle.py
+++ b/bottle.py
@@ -782,7 +782,8 @@ class Bottle(object):
# Empty output is done here
if not out:
- response['Content-Length'] = 0
+ if 'Content-Length' not in response:
+ response['Content-Length'] = 0
return []
# Join lists of byte or unicode strings. Mixed lists are NOT supported
if isinstance(out, (tuple, list))\
@@ -793,15 +794,14 @@ class Bottle(object):
out = out.encode(response.charset)
# Byte Strings are just returned
if isinstance(out, bytes):
- response['Content-Length'] = len(out)
+ if 'Content-Length' not in response:
+ response['Content-Length'] = len(out)
return [out]
# HTTPError or HTTPException (recursive, because they may wrap anything)
# TODO: Handle these explicitly in handle() or make them iterable.
if isinstance(out, HTTPError):
out.apply(response)
out = self.error_handler.get(out.status_code, self.default_error_handler)(out)
- if isinstance(out, HTTPResponse):
- depr('Error handlers must not return :exc:`HTTPResponse`.') #0.9
return self._cast(out)
if isinstance(out, HTTPResponse):
out.apply(response)