Commit c7ab79ce authored by Casey Duncan's avatar Casey Duncan

Remove Content-Length HTTP header from 304 responses which violates RFC 2616....

Remove Content-Length HTTP header from 304 responses which violates RFC 2616. This was a workaround for a (fixed) apache proxy-cache bug. (Issue #544)
parent f654a4f8
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
############################################################################## ##############################################################################
"""Image object""" """Image object"""
__version__='$Revision: 1.151 $'[11:-2] __version__='$Revision: 1.152 $'[11:-2]
import Globals, struct import Globals, struct
from OFS.content_types import guess_content_type from OFS.content_types import guess_content_type
...@@ -150,12 +150,9 @@ class File(Persistent, Implicit, PropertyManager, ...@@ -150,12 +150,9 @@ class File(Persistent, Implicit, PropertyManager,
else: else:
last_mod = long(0) last_mod = long(0)
if last_mod > 0 and last_mod <= mod_since: if last_mod > 0 and last_mod <= mod_since:
# Set header values since apache caching will return
# Content-Length of 0 in response if size is not set here
RESPONSE.setHeader('Last-Modified', RESPONSE.setHeader('Last-Modified',
rfc1123_date(self._p_mtime)) rfc1123_date(self._p_mtime))
RESPONSE.setHeader('Content-Type', self.content_type) RESPONSE.setHeader('Content-Type', self.content_type)
RESPONSE.setHeader('Content-Length', self.size)
RESPONSE.setHeader('Accept-Ranges', 'bytes') RESPONSE.setHeader('Accept-Ranges', 'bytes')
RESPONSE.setStatus(304) RESPONSE.setStatus(304)
return True return True
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment