summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-09-10 19:37:48 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2011-09-10 19:37:48 +0200
commit121798bae3b94492826706017c1a2d0f0d71454a (patch)
treedfbb84125f3af770d181f91194141e0c2e8a435e
parent360d0a628a8264fb100b9c52c0e4adf0b6421ad3 (diff)
Handle rfc1123 dates with timezone names.
-rwxr-xr-xfbin.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/fbin.py b/fbin.py
index 14ba18d..75a0343 100755
--- a/fbin.py
+++ b/fbin.py
@@ -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):