Closed stricaud closed 1 year ago
I am getting various exceptions like this:
[2023-02-24 22:41:25 +0100] [512643] [ERROR] Exception in static request handler: path=static, relative_url=fonts/general.woff2 Traceback (most recent call last): File "/home/sebastien/.local/lib/python3.11/site-packages/sanic/mixins/routes.py", line 848, in _static_request_handler response = await validate_file(request.headers, modified_since) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/sebastien/.local/lib/python3.11/site-packages/sanic/response/convenience.py", line 151, in validate_file if last_modified <= if_modified_since: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: can't compare offset-naive and offset-aware datetimes
Which is fixed by ensuring last_modified and if_modified_since are converted to proper timestamps():
if last_modified.timestamp() <= if_modified_since.timestamp():
No response
Sanic CLI
Linux Debian
Sanic 22.12.0; Routing 22.8.0
Excellent. Can you open a PR with this fix and a unit test?
absolutely
Done with PR #2697 2697
Is there an existing issue for this?
Describe the bug
I am getting various exceptions like this:
Which is fixed by ensuring last_modified and if_modified_since are converted to proper timestamps():
Code snippet
No response
Expected Behavior
No response
How do you run Sanic?
Sanic CLI
Operating System
Linux Debian
Sanic Version
Sanic 22.12.0; Routing 22.8.0
Additional context
No response