Skip to content

Add optional external file delivery #1

Description

@QuickWrite

Problem

Shared file downloads are always streamed through PHP (FileResponse::send() -> fopen + chunked echo). This holds a PHP worker open for the entire download, has no range-resume support, and is inefficient for large files. This is especially bad when mutliple files are sent at the same time and they are blocking other requests because of it.

When running behind a proxy, it would be better to hand file delivery off to the web server when possible. For example the Apache server has the ability to send a file when receiving the X-Sendfile-header.

I do not want remove the existing PHP streaming code. It is useful (built-in server, Nginx-less setups, environments without mod_xsendfile) and must remain the default/fallback.

Changes

  • Add KITTYSHARE_FILE_DELIVERY=php|x-sendfile (default: php).
  • Parse it in ConfigManager, store as a typed field on Config
  • In FileResponse, when mode is x-sendfile: send Content-Type, Content-Length, and the existing X-Content-Type-Options / Content-Security-Policy headers plus X-Sendfile: <absolute path>, with no response body.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions