D3435: hgweb: discard Content-Type header for 304 responses (issue5844)
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Thu May 3 02:25:35 UTC 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG11ee9bf24791: hgweb: discard Content-Type header for 304 responses (issue5844) (authored by indygreg, committed by ).
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D3435?vs=8443&id=8447
REVISION DETAIL
https://phab.mercurial-scm.org/D3435
AFFECTED FILES
mercurial/hgweb/hgweb_mod.py
tests/test-hgweb.t
CHANGE DETAILS
diff --git a/tests/test-hgweb.t b/tests/test-hgweb.t
--- a/tests/test-hgweb.t
+++ b/tests/test-hgweb.t
@@ -890,9 +890,7 @@
200 Script output follows
content-length: 2677
content-type: text/css
- 500 Internal Server Error
- transfer-encoding: chunked
- [1]
+ 304 Not Modified
$ killdaemons.py
diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -399,6 +399,12 @@
tag = 'W/"%d"' % self.mtime
if req.headers.get('If-None-Match') == tag:
res.status = '304 Not Modified'
+ # Content-Type may be defined globally. It isn't valid on a
+ # 304, so discard it.
+ try:
+ del res.headers[b'Content-Type']
+ except KeyError:
+ pass
# Response body not allowed on 304.
res.setbodybytes('')
return res.sendresponse()
To: indygreg, #hg-reviewers, krbullock
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list