diff options
author | Josef Gajdusek <atx@atx.name> | 2017-11-05 13:59:45 +0100 |
---|---|---|
committer | Josef Gajdusek <atx@atx.name> | 2017-11-05 20:15:33 +0100 |
commit | 443491630426c79befcc19f3c3bb4e654a6a25e5 (patch) | |
tree | b3b27df9f4b2577d74cdd6fea22039d2f9d6e229 | |
parent | db8da3a6aab1142ea0694963eb9afb5026c3c467 (diff) | |
download | bottle-443491630426c79befcc19f3c3bb4e654a6a25e5.tar.gz |
Fix Last-Modifed and Date header formats in static_file for non-english locales
time.strftime produces locale-dependent date format. At best, this lead to
invalid dates being produced, e. g: 'Ne, 05 lis 2017 12:58:28 GMT'. At worst,
this lead to encoding crashes for dates like 'Út, 31 říj 2017 12:58:28 GMT'
-rwxr-xr-x | bottle.py | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -2884,9 +2884,9 @@ def static_file(filename, root, stats = os.stat(filename) headers['Content-Length'] = clen = stats.st_size - lm = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(stats.st_mtime)) - headers['Last-Modified'] = lm - headers['Date'] = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime()) + headers['Last-Modified'] = email.utils.formatdate(stats.st_mtime, + usegmt=True) + headers['Date'] = email.utils.formatdate(time.time(), usegmt=True) getenv = request.environ.get |