[Lispweb] [Araneida] Using TBNL with Araneida

Bob Hutchison hutch at recursive.ca
Sat Mar 12 08:33:18 CST 2005


Hi,

I have been developing an application using mod_lisp/TBNL and have been 
very happy with the combination. As the project progressed the desire 
for a stand-alone version of the application has become overwhelming 
:-) Since I've used Araneida for prototyping in the past and liked it, 
I thought that using Araneida with TBNL would be a nice combination.

I've got this working. It consists of an in-the-end surprisingly simple 
handle-request-response method and a few relatively minor changes to 
both TBNL and Araneida. I've been in touch with Edi Weitz regarding the 
changes to TBNL and will send him a patch. Now I need to talk to the 
Araneida developers about the change to Araneida that I made.

The difficulty was that Araneida and TBNL take slightly different 
approaches to handling the body of an HTTP request. Araneida parses the 
body immediately (and I *think* assumes form encoding) where TBNL takes 
a lazy approach (and deals with multipart encodings). What I did was to 
add a new slot to the Araneida request class that records the 
body-string sent to the function parse-body (in daemon.lisp). I can 
then, before invoking TBNL, do this kind of thing:

     (with-input-from-string (input (map 'string
                                         (lambda (c) (code-char c))
                                         (request-unparsed-body 
request)))
       (with-open-stream (tbnl::*apache-stream* (MAKE-TWO-WAY-STREAM 
input
                                                                     
(request-stream request)))



The reason I had to do this is that the decision to parse or not parse 
the body is taken *before* the handler is determined. The consequence 
is that the body parsing done by Araneida is ignored and TBNL does it 
instead. Ideally the parsing of the body could be deferred until it is 
asked for. There is a possible problem when uploading files -- 
Lispworks as a limit on the size of arrays which would restrict upload 
to something like a megabyte. I'm assuming that Araneida consumes the 
entire input stream, if it doesn't then this will be another problem 
because TBNL won't get it using the scheme I've introduced.

NOTE: that mapping over the unparsed body might be a Lispworks-ism.

For Lispworks, I made another small change that allows UTF-8 to be 
served.

I can provide a patch to Araneida 0.9 if somebody will tell me who to 
send it to.

----
Bob Hutchison          -- blogs at <http://www.recursive.ca/hutch/>
Recursive Design Inc.  -- <http://www.recursive.ca/>




More information about the lispweb mailing list