Skip to content

Commit

Permalink
Ignore unparsable If-Modified-Since headers and return the file
Browse files Browse the repository at this point in the history
Firefox 91 mangling the If-Modified-Since request header with a
(perhaps) fractional second?
  • Loading branch information
Daniele Gozzi committed Jul 16, 2021
1 parent 855c05e commit 5b58695
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 5b58695

Please sign in to comment.