[Bese-devel] Re: generated content with ucw

Attila Lendvai attila.lendvai at gmail.com
Sat Feb 18 10:50:00 UTC 2006


> you could try to first call (shutdown (context.request *context*)), this
> should write out the headers, and then write directly to the
> content-stream (which is, unfortunetly, backend specific).

success! i had to make a small dirty change to ucw: introduce a validp
flag on the httpd response and handle double shutdown calls and empty
responses. but with this i can serve cairo generated png's with ucw...
:)

> ucw would be better with it, but i don't know when i'll get around to
> it. it's not that hard really, but will require some carefull refactoring.

yep, that's why i don't apply it to the public repo... looking forward
to a patch, but it fine until then.

- attila

(alias 101 on irc &no 'its not lisp code :)

ps:

(defcomponent binary-content-component (window-component)
  ((data :initarg :data :accessor data-of))
  (:default-initargs
      :content-type "application/octet-stream")
  (:render (self)
           (let* ((response (ucw::context.response *context*))
                  (request (ucw::context.request *context*))
                  (content (data-of self))
                  (stream (ucw::network-stream request)))
             (ucw::shutdown response)
             (log.debug "Writing ~A bytes long binary content to the
output stream"
                        (length content))
             (ucw::write-header-line "Content-Length" (princ-to-string
(length content)) stream)
             (ucw::write-crlf stream)
             (write-sequence content stream))))

(defmethod serve-binary-content (byte-vector &key (content-type
"application/octet-stream"))
  (setf (context.window-component *context*)
        (make-instance 'binary-content-component :data byte-vector
:content-type content-type)))



More information about the bese-devel mailing list