Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore unparsable If-Modified-Since headers and return the file #287

Merged
merged 1 commit into from Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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