Closed a13x closed 7 years ago
If serving an PNG file is what you want to do, just return a pathname at the body position (the third value of the response list).
I'm generating a PNG image on the fly (as shown in the gist) so that's not an option :)
Well, first of all, your code doesn't stream the content. It creates a binary sequence and returns it.
I don't know where the with-output-to-sequence
from and what is the type of its response, but it may work if you coerce it to a simple-vector.
See Lack's README what is valid for the body.
The response body must be returned from the application in one of three formats, a list of strings, a byte vectors, or a pathname. https://github.com/fukamachi/lack#normal-response
And see this for getting the way to actually stream it is: https://github.com/fukamachi/lack#delayed-response-and-streaming-body
Apologies for using the term streaming :) (with-output-to-sequence) comes from babel-streams and I use it to save png image to a binary sequence (using vecto:save-png-stream) so by streaming I meant streaming into a sequence and returning it.
The output of a with-output-to-sequence is a (VECTOR (UNSIGNED-BYTE 8) as specified in element-type.
Even if I call babel:octets-to-string to convert the vector to a string and return it, woo complains (with the same error as above).
The same code (in the gist) works just fine if I use :server 'hunchentoot when starting clack, so I believe the issue lies in woo.
Since there's no replies, I guess I'll just dig deeper into woo code and try to fix it myself. From the perspective of clack, it looks like a bug or missing functionality in woo, since code without coercion works fine with other servers (hunchentoot and wookie).
I wrote a simple demo app with ningle and clack running on woo server serving PNG images (gist: here). When I output the stream of created image directly in the handler, the server fails on woo with the following error:
The code works fine on hunchentoot. The only way i figured this working is to coerce a stream into a simple-array:
(coerce output '(simple-array (unsigned-byte 8) (*))
That just looks weird to me - woo should be able to handle outputting to stream so it seems to me I'm doing something wrong.