For one of my projects I encountered the issue of sending a large file as an HTTP response from Clack.

Clack supports sending files as a response with Hunchentoot, FCGI and Wookie back-ends. If you use Toot as back-end you will have to implement your own method.

To send a file, return the file’s path as a PATHNAME (#P"/path/to/file") as the response body.

The different back-ends use different methods to send a file. This has other implications which you may want to consider.

Server Method Notes
Hunchentoot HTTP Chunking
  • Optimal for large files.
  • Does not load whole file into RAM.
  • Multiple small messages.
Wookie Byte stream
  • Does not load whole file into RAM.
  • Single large message.
FCGI Array
  • Loads the whole file into RAM.
  • Single large message.
Toot DIY