falconry / falcon

The no-magic web data plane API and microservices framework for Python developers, with a focus on reliability, correctness, and performance at scale.
https://falcon.readthedocs.io/en/stable/
Apache License 2.0
9.51k stars 937 forks source link

feat(static): set `Content-Length` for static file responses #1991

Closed vytas7 closed 2 years ago

vytas7 commented 2 years ago

Also fix range request support across different WSGI servers by always providing a Python wrapper without a file descriptor, since many sendfile implementations are buggy wrt not respecting the current file offset; both Gunicorn (https://github.com/benoitc/gunicorn/issues/2669) and uWSGI are affected according to my testing.

There is still an open question remaining what to do with Meinheld: I've filed this as a separate issue (#1992).

codecov[bot] commented 2 years ago

Codecov Report

Merging #1991 (ca4e279) into master (73b90c2) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1991   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           63        63           
  Lines         6669      6674    +5     
  Branches      1079      1079           
=========================================
+ Hits          6669      6674    +5     
Impacted Files Coverage Δ
falcon/app.py 100.00% <ø> (ø)
falcon/routing/static.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 73b90c2...ca4e279. Read the comment docs.

vytas7 commented 2 years ago

We already have unit tests covering ASGI too, but I will check if all the functionality is verified in unit tests as well.

Otherwise, ASGI has no concept of sendfile, and the response is rendered purely by the app, so adequate unit testing should be enough.