diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-01-06 17:17:04 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-01-06 17:17:04 (GMT) |
commit | b715fac819fadf56dc8ae0a7769e20ec053baa6d (patch) | |
tree | 63548aa14a5790075cdbceefd7a7522e86e2129d /Lib/wsgiref/handlers.py | |
parent | f1397ad3999b9a12b47ecc17ba2c7b5bce0a9f2e (diff) | |
download | cpython-b715fac819fadf56dc8ae0a7769e20ec053baa6d.zip cpython-b715fac819fadf56dc8ae0a7769e20ec053baa6d.tar.gz cpython-b715fac819fadf56dc8ae0a7769e20ec053baa6d.tar.bz2 |
Issue #3839: wsgiref should not override a Content-Length header set by
the application. Initial patch by Clovis Fabricio.
Diffstat (limited to 'Lib/wsgiref/handlers.py')
-rw-r--r-- | Lib/wsgiref/handlers.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/wsgiref/handlers.py b/Lib/wsgiref/handlers.py index 6d6f80f..67064a6 100644 --- a/Lib/wsgiref/handlers.py +++ b/Lib/wsgiref/handlers.py @@ -302,7 +302,9 @@ class BaseHandler: def finish_content(self): """Ensure headers and content have both been sent""" if not self.headers_sent: - self.headers['Content-Length'] = "0" + # Only zero Content-Length if not set by the application (so + # that HEAD requests can be satisfied properly, see #3839) + self.headers.setdefault('Content-Length', "0") self.send_headers() else: pass # XXX check if content-length was too short? |