Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hgweb/request.py @ 12739:8dcd3203a261
hgweb: don't send a body or illegal headers during 304 response
Without this fix, mod_wsgi and spawning get in a wedged state after
sending a 304 response. Not sending a body fixed that problem. The
header change was discovered by using wsgiref.validate.validator to
check for other errors.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Sat, 16 Oct 2010 17:29:04 -0500 |
parents | 25e572394f5c |
children | e5d3c7083d91 |
line wrap: on
line diff
--- a/mercurial/hgweb/request.py Sat Oct 16 22:40:46 2010 +0200 +++ b/mercurial/hgweb/request.py Sat Oct 16 17:29:04 2010 -0500 @@ -8,7 +8,7 @@ import socket, cgi, errno from mercurial import util -from common import ErrorResponse, statusmessage +from common import ErrorResponse, statusmessage, HTTP_NOT_MODIFIED shortcuts = { 'cl': [('cmd', ['changelog']), ('rev', None)], @@ -83,6 +83,13 @@ if isinstance(status, ErrorResponse): self.header(status.headers) + if status.code == HTTP_NOT_MODIFIED: + # RFC 2616 Section 10.3.5: 304 Not Modified has cases where + # it MUST NOT include any headers other than these and no + # body + self.headers = [(k, v) for (k, v) in self.headers if + k in ('Date', 'ETag', 'Expires', + 'Cache-Control', 'Vary')] status = statusmessage(status.code, status.message) elif status == 200: status = '200 Script output follows'