summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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):