Skip to content

404 returned if only compressed file exists #8182

Closed
@steverep

Description

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions