##// END OF EJS Templates
hgweb: inline caching() and port to modern mechanisms...
Gregory Szorc -
r36885:7ad6a275 default
parent child Browse files
Show More
@@ -214,12 +214,6 b' def get_contact(config):'
214 config("ui", "username") or
214 config("ui", "username") or
215 encoding.environ.get("EMAIL") or "")
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 def cspvalues(ui):
217 def cspvalues(ui):
224 """Obtain the Content-Security-Policy header and nonce value.
218 """Obtain the Content-Security-Policy header and nonce value.
225
219
@@ -18,7 +18,6 b' from .common import ('
18 HTTP_NOT_MODIFIED,
18 HTTP_NOT_MODIFIED,
19 HTTP_OK,
19 HTTP_OK,
20 HTTP_SERVER_ERROR,
20 HTTP_SERVER_ERROR,
21 caching,
22 cspvalues,
21 cspvalues,
23 permhooks,
22 permhooks,
24 )
23 )
@@ -388,7 +387,13 b' class hgweb(object):'
388 # Don't enable caching if using a CSP nonce because then it wouldn't
387 # Don't enable caching if using a CSP nonce because then it wouldn't
389 # be a nonce.
388 # be a nonce.
390 if rctx.configbool('web', 'cache') and not rctx.nonce:
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 if cmd not in webcommands.__all__:
397 if cmd not in webcommands.__all__:
393 msg = 'no such method: %s' % cmd
398 msg = 'no such method: %s' % cmd
394 raise ErrorResponse(HTTP_BAD_REQUEST, msg)
399 raise ErrorResponse(HTTP_BAD_REQUEST, msg)
General Comments 0
You need to be logged in to leave comments. Login now