Show More
@@ -214,12 +214,6 b' def get_contact(config):' | |||
|
214 | 214 | config("ui", "username") or |
|
215 | 215 | encoding.environ.get("EMAIL") or "") |
|
216 | 216 | |
|
217 | def caching(web, req): | |
|
218 | tag = r'W/"%d"' % web.mtime | |
|
219 | if req.env.get('HTTP_IF_NONE_MATCH') == tag: | |
|
220 | raise ErrorResponse(HTTP_NOT_MODIFIED) | |
|
221 | req.headers.append(('ETag', tag)) | |
|
222 | ||
|
223 | 217 | def cspvalues(ui): |
|
224 | 218 | """Obtain the Content-Security-Policy header and nonce value. |
|
225 | 219 |
@@ -18,7 +18,6 b' from .common import (' | |||
|
18 | 18 | HTTP_NOT_MODIFIED, |
|
19 | 19 | HTTP_OK, |
|
20 | 20 | HTTP_SERVER_ERROR, |
|
21 | caching, | |
|
22 | 21 | cspvalues, |
|
23 | 22 | permhooks, |
|
24 | 23 | ) |
@@ -388,7 +387,13 b' class hgweb(object):' | |||
|
388 | 387 | # Don't enable caching if using a CSP nonce because then it wouldn't |
|
389 | 388 | # be a nonce. |
|
390 | 389 | if rctx.configbool('web', 'cache') and not rctx.nonce: |
|
391 | caching(self, wsgireq) # sets ETag header or raises NOT_MODIFIED | |
|
390 | tag = 'W/"%d"' % self.mtime | |
|
391 | if req.headers.get('If-None-Match') == tag: | |
|
392 | raise ErrorResponse(HTTP_NOT_MODIFIED) | |
|
393 | ||
|
394 | wsgireq.headers.append((r'ETag', pycompat.sysstr(tag))) | |
|
395 | res.headers['ETag'] = tag | |
|
396 | ||
|
392 | 397 | if cmd not in webcommands.__all__: |
|
393 | 398 | msg = 'no such method: %s' % cmd |
|
394 | 399 | raise ErrorResponse(HTTP_BAD_REQUEST, msg) |
General Comments 0
You need to be logged in to leave comments.
Login now