[Bese-devel] Send-headers Troubles
Attila Lendvai
attila.lendvai at gmail.com
Fri Feb 8 00:22:17 UTC 2008
> I am having a bit of trouble with some code that used to work with
> ucw_dev, but throws an error in ucw_ajax. I have an audio-file-window
> that is designed to stream audio files to a client:
>
> (defcomponent audio-file-window (window-component)
> ((audio-file :initarg :audio-file :accessor audio-file)))
>
> (defmethod window-component.content-type ((window audio-file-window))
> (audio-file-type (audio-file window)))
>
> ;; attempted solution that does not work
> (defmethod render :before ((audio-window audio-file-window))
> (setf (get-header (context.response *context*) "Content-Length")
> (format nil "~D" (audio-file-length (audio-file audio-window)))))
>
> (defmethod render ((audio-window audio-file-window))
> (send-headers (context.response *context*)) ; erring line
> (write-sequence (audio-data (audio-file audio-window))
> (ucw::network-stream (context.response *context*))))
the problem (that ucw_dev silently ignored) is that if you don't tell
ucw that you are handling the request all together, then it will try
to send the header at the end of the render loop, thus sending the
headers twice.
we could argue that the error should not be thrown when the headers
are tried to be sent twice, but when a header is tried to be added to
the response after the headers have been sent. i'll add this to my
todo and most probably implement in the next weeks.
until then you can use (handle-raw-request (:content-type "text/plain
or whatever") ...) from render
or use the handle-raw-request from action-href-body
(action-href-body (:raw t)
(handle-raw-request (:content-type "text/plain")
...))
to create a non-entrypoint link which is when requested will sent the raw data.
hth,
--
attila
More information about the bese-devel
mailing list