##// END OF EJS Templates
hgweb: don't send a body or illegal headers during 304 response...
Augie Fackler -
r12739:8dcd3203 default
parent child Browse files
Show More
@@ -9,7 +9,8 b''
9 import os
9 import os
10 from mercurial import ui, hg, hook, error, encoding, templater
10 from mercurial import ui, hg, hook, error, encoding, templater
11 from common import get_mtime, ErrorResponse, permhooks, caching
11 from common import get_mtime, ErrorResponse, permhooks, caching
12 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
12 from common import HTTP_OK, HTTP_NOT_MODIFIED, HTTP_BAD_REQUEST
13 from common import HTTP_NOT_FOUND, HTTP_SERVER_ERROR
13 from request import wsgirequest
14 from request import wsgirequest
14 import webcommands, protocol, webutil
15 import webcommands, protocol, webutil
15
16
@@ -202,6 +203,9 b' class hgweb(object):'
202 return tmpl('error', error=str(inst))
203 return tmpl('error', error=str(inst))
203 except ErrorResponse, inst:
204 except ErrorResponse, inst:
204 req.respond(inst, ctype)
205 req.respond(inst, ctype)
206 if inst.code == HTTP_NOT_MODIFIED:
207 # Not allowed to return a body on a 304
208 return ['']
205 return tmpl('error', error=inst.message)
209 return tmpl('error', error=inst.message)
206
210
207 def templater(self, req):
211 def templater(self, req):
@@ -8,7 +8,7 b''
8
8
9 import socket, cgi, errno
9 import socket, cgi, errno
10 from mercurial import util
10 from mercurial import util
11 from common import ErrorResponse, statusmessage
11 from common import ErrorResponse, statusmessage, HTTP_NOT_MODIFIED
12
12
13 shortcuts = {
13 shortcuts = {
14 'cl': [('cmd', ['changelog']), ('rev', None)],
14 'cl': [('cmd', ['changelog']), ('rev', None)],
@@ -83,6 +83,13 b' class wsgirequest(object):'
83
83
84 if isinstance(status, ErrorResponse):
84 if isinstance(status, ErrorResponse):
85 self.header(status.headers)
85 self.header(status.headers)
86 if status.code == HTTP_NOT_MODIFIED:
87 # RFC 2616 Section 10.3.5: 304 Not Modified has cases where
88 # it MUST NOT include any headers other than these and no
89 # body
90 self.headers = [(k, v) for (k, v) in self.headers if
91 k in ('Date', 'ETag', 'Expires',
92 'Cache-Control', 'Vary')]
86 status = statusmessage(status.code, status.message)
93 status = statusmessage(status.code, status.message)
87 elif status == 200:
94 elif status == 200:
88 status = '200 Script output follows'
95 status = '200 Script output follows'
General Comments 0
You need to be logged in to leave comments. Login now