starlette icon indicating copy to clipboard operation
starlette copied to clipboard

Support returning Not Modified responses in FileResponse

Open paulo-raca opened this issue 6 months ago • 2 comments

Summary

Looking at the souce for StaticFiles, it verifies the timestamp/etag and returns HTTP 304 - Not Modified when appropriate.

IMHO it would be simpler / more reusable if this was part of FileResponse.

(I brought this up a few hours ago in #2954, and decided to give it a try)

I haven't written new tests: There already is a ton of them and there is good coverage.

Checklist

  • [x] I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • [ ] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • [ ] I've updated the documentation accordingly.

paulo-raca avatar Jun 25 '25 22:06 paulo-raca

@abersheeran I know you've played a lot with this. Does this PR make sense?

Kludex avatar Jun 26 '25 09:06 Kludex

Hello, is this related to https://github.com/encode/starlette/pull/2891 ?

Smixi-syn avatar Jul 22 '25 13:07 Smixi-syn