[hunchentoot-devel] send-headers and SBCL's run-program
Alexey Martynov
martynov.alexey at gmail.com
Tue Feb 1 07:00:17 UTC 2011
Hi
I have following problem: I need to run external script which outputs
image to standard output. To deliver it to client I use
hunchentoot:send-headers call.
Following code works fine:
(setf (hunchentoot:content-type*) "image/png")
(setf (hunchentoot:header-out "Pragma") "no-cache")
(let ((out (hunchentoot:send-headers)))
(let ((process (sb-ext:run-program "generate-image" '()
:output :stream
:wait nil
:error nil)))
(let ((file (sb-ext:process-output process)))
(loop with buf = (make-array 10240 :element-type
'(unsigned-byte 8))
for pos = (read-sequence buf file)
until (zerop pos)
do (write-sequence buf out :end pos)))))
But when I want to use stream from "send-headers" as stream for
standard output for external program then status line and headers
received after image content. I use following code:
(setf (hunchentoot:content-type*) "image/png")
(setf (hunchentoot:header-out "Pragma") "no-cache")
(let ((out (hunchentoot:send-headers)))
(let ((process (sb-ext:run-program "generate-image" '()
:output out
:wait nil
:error nil)))
(sb-ext:process-wait process)))
So I have following question: is it possible to use stream received
from "send-headers" as output stream for spawned process or not? If
yes how correct code must look?
Thanks in advance
--
Alexey Martynov
More information about the Tbnl-devel
mailing list