Mercurial > piecrust2
diff piecrust/serving/util.py @ 1095:c8518f5cedbb
serve: Do some more useful debug logging when serving assets.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 17 Feb 2018 11:50:42 -0800 |
parents | 8adc27285d93 |
children | e94737572542 |
line wrap: on
line diff
--- a/piecrust/serving/util.py Sat Feb 17 11:50:17 2018 -0800 +++ b/piecrust/serving/util.py Sat Feb 17 11:50:42 2018 -0800 @@ -107,17 +107,17 @@ def make_wrapped_file_response(environ, request, path): - logger.debug("Serving %s" % path) - # Check if we can return a 304 status code. mtime = os.path.getmtime(path) etag_str = '%s$$%s' % (path, mtime) etag = hashlib.md5(etag_str.encode('utf8')).hexdigest() if etag in request.if_none_match: + logger.debug("Serving %s [no download, E-Tag matches]" % path) response = Response() response.status_code = 304 return response + logger.debug("Serving %s [full download]" % path) wrapper = wrap_file(environ, open(path, 'rb')) response = Response(wrapper) _, ext = os.path.splitext(path)