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 |
|
[Clack] comes with separate middleware modules for session
management and for storing session information in a database. I
discovered the storage middleware shortly after implementing my own version.
Update (2016-04-02): @abeaumont pointed out that the hashing
issue has already been fixed in the Github repo. As of today Quicklisp
provides Ironclad version 0.33.0 which dates back to 2014. Until Quicklisp
provides an updated version the information in this post is still relevant.