Skip to content

Commit

Permalink
web: do not send 500 on invalid If-Modified-Since header
Browse files Browse the repository at this point in the history
  • Loading branch information
rgajrawala authored Jul 8, 2024
1 parent e978117 commit 0577219
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tornado/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -2861,7 +2861,10 @@ def should_return_304(self) -> bool:
# content has not been modified
ims_value = self.request.headers.get("If-Modified-Since")
if ims_value is not None:
if_since = email.utils.parsedate_to_datetime(ims_value)
try:
if_since = email.utils.parsedate_to_datetime(ims_value)
except ValueError:
return False
if if_since.tzinfo is None:
if_since = if_since.replace(tzinfo=datetime.timezone.utc)
assert self.modified is not None
Expand Down

0 comments on commit 0577219

Please sign in to comment.