Skip to content

Commit

Permalink
Merge pull request #287 from danielegozzi/master
Browse files Browse the repository at this point in the history
Ignore unparsable If-Modified-Since headers and return the file
  • Loading branch information
evansd committed Jul 16, 2021
2 parents 855c05e + 5b58695 commit e504d4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tests/test_whitenoise.py
Expand Up @@ -117,6 +117,10 @@ def test_modified(server, files):
response = server.get(files.js_url, headers={"If-Modified-Since": last_mod})
assert response.status_code == 200

def test_modified_mangled_date_firefox_91_0b3(server, files):
last_mod = "Fri, 16 Jul 2021 09:09:1626426577S GMT"
response = server.get(files.js_url, headers={"If-Modified-Since": last_mod})
assert response.status_code == 200

def test_etag_matches(server, files):
response = server.get(files.js_url)
Expand Down
5 changes: 4 additions & 1 deletion whitenoise/responders.py
Expand Up @@ -182,7 +182,10 @@ def is_not_modified(self, request_headers):
last_requested = request_headers["HTTP_IF_MODIFIED_SINCE"]
except KeyError:
return False
return parsedate(last_requested) >= self.last_modified
last_requested_ts = parsedate(last_requested)
if last_requested_ts is not None:
return parsedate(last_requested) >= self.last_modified
return False

def get_path_and_headers(self, request_headers):
accept_encoding = request_headers.get("HTTP_ACCEPT_ENCODING", "")
Expand Down

0 comments on commit e504d4a

Please sign in to comment.