diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-09-10 19:37:48 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-09-10 19:37:48 +0200 |
commit | 121798bae3b94492826706017c1a2d0f0d71454a (patch) | |
tree | dfbb84125f3af770d181f91194141e0c2e8a435e | |
parent | 360d0a628a8264fb100b9c52c0e4adf0b6421ad3 (diff) |
Handle rfc1123 dates with timezone names.
-rwxr-xr-x | fbin.py | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -6,6 +6,7 @@ from PIL import Image base62_alphabet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' rfc1123_format = '%a, %d %b %Y %H:%M:%S +0000' +rfc1123_format_tzname = '%a, %d %b %Y %H:%M:%S %Z' if not os.path.isdir(settings.file_directory): os.mkdir(settings.file_directory) @@ -124,7 +125,11 @@ class Application(object): def not_modified(self, environ, date): if not 'HTTP_IF_MODIFIED_SINCE' in environ: return False - mod_since_date = datetime.datetime.strptime(environ['HTTP_IF_MODIFIED_SINCE'], rfc1123_format) + try: + mod_since_date = datetime.datetime.strptime(environ['HTTP_IF_MODIFIED_SINCE'], rfc1123_format) + except ValueError: + # some clients use timezone names (eg. GMT) instead of numeric timezones + mod_since_date = datetime.datetime.strptime(environ['HTTP_IF_MODIFIED_SINCE'], rfc1123_format_tzname) return date == mod_since_date def file(self, environ, start_response, path): |