comparison mercurial/hgweb/common.py @ 12183:f64b416b0ac8

hgweb: support very simple caching model (issue1845)
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Wed, 08 Sep 2010 15:23:48 +0200
parents d6512b3e9ac0
children 14f3795a5ed7
comparison
equal deleted inserted replaced
12182:1121af239761 12183:f64b416b0ac8
7 # GNU General Public License version 2 or any later version. 7 # GNU General Public License version 2 or any later version.
8 8
9 import errno, mimetypes, os 9 import errno, mimetypes, os
10 10
11 HTTP_OK = 200 11 HTTP_OK = 200
12 HTTP_NOT_MODIFIED = 304
12 HTTP_BAD_REQUEST = 400 13 HTTP_BAD_REQUEST = 400
13 HTTP_UNAUTHORIZED = 401 14 HTTP_UNAUTHORIZED = 401
14 HTTP_FORBIDDEN = 403 15 HTTP_FORBIDDEN = 403
15 HTTP_NOT_FOUND = 404 16 HTTP_NOT_FOUND = 404
16 HTTP_METHOD_NOT_ALLOWED = 405 17 HTTP_METHOD_NOT_ALLOWED = 405
150 ui.username or $EMAIL as a fallback to display something useful. 151 ui.username or $EMAIL as a fallback to display something useful.
151 """ 152 """
152 return (config("web", "contact") or 153 return (config("web", "contact") or
153 config("ui", "username") or 154 config("ui", "username") or
154 os.environ.get("EMAIL") or "") 155 os.environ.get("EMAIL") or "")
156
157 def caching(web, req):
158 tag = str(web.mtime)
159 if req.env.get('HTTP_IF_NONE_MATCH') == tag:
160 raise ErrorResponse(HTTP_NOT_MODIFIED)
161 req.headers.append(('ETag', tag))