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

404 returned if only compressed file exists #8182

Open
1 task done
steverep opened this issue Feb 23, 2024 · 0 comments
Open
1 task done

404 returned if only compressed file exists #8182

steverep opened this issue Feb 23, 2024 · 0 comments

Comments

@steverep
Copy link
Contributor

Is your feature request related to a problem?

Currently, the StaticResource handler immediately returns a 404 status if the requested file is not on disk: elif filepath.is_file():. This is done before the response class checks for compressed versions of the file, making it impossible to store only compressed versions of static resources in order to conserve disk space.

Furthermore, this is an extra unnecessary call for a file system operation that should be eliminated to gain performance. The file response class already gets a stat of the file in the executor to get things like the content length.

Describe the solution you'd like

  • Return the compressed file when permitted by the Accept-Encoding header, regardless of uncompressed existence.
  • Return a 406 if the compression is not supported by the client, or permit dynamic decompression.
  • Eliminate the extra is_file() check.

Describe alternatives you've considered

Only solution is to make sure uncompressed files always exist.

Related component

Server

Additional context

Technically, I think serving a 404 when a representation with a supported content coding exists is a violation of RFC 9110.

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant