Hi,
Attached is a patch with my stab at file upload capabilities for TBNL. :)
[To my defense, I first played around with rfc2388. Then I switched to TBNL and found it to be rather straight-forward to add this functionality. Only afterwards I found out about the efforts of others regarding file uploads for TBNL.]
Anyway, here's what the patch is about:
* Adds support for multipart/form-data forms.
* Can parse rfc2388 MIME data.
* Enables file upload.
* Introduces POST-PARAMETER* and POST-PARAMETERS* to give richer information about posted data (MIME headers). Also, the starred versions collate parameters with equal name into a list. + If successful, POST-PARAMETER* returns a list of MIME-PARTs, each of which can be further poked at with accessors exported from RFC2388. + POST-PARAMETERS* returns the corresponding hash-table.
* Is backwards compatible with original TBNL, although the old interface is less efficiently implemented now (conses more).
* Uses a slightly patched rfc2388.lisp (http://common-lisp.net/project/rfc2388) by Janis Dzerins, which is included completely in the patch.
* Adds a file upload example to test/test.lisp (sessions.html). It is not very polished, though.
Issues: * I tested with SBCL-0.8.15, and occasionally I get Apache "internal server errors" (caused by SIGPIPE errors on the Lisp side). It seems to be dependant on which file is uploaded. I did not look into it yet... * DOES NOT provide functionality to handle transfer encodings. The application is on its own there for now.
Mind you, the whole thing is just a first try. Perhaps it needs a better/richer API, too, but this one is simple, and works for me, YMMV.
Cheers, Michael p.s.: I noticed, there is at least one other CL rfc2388 implementation available, in mel-base.
On Wed, 27 Oct 2004 23:04:17 +0200, Michael Weber michaelw+tbnl@foldr.org wrote:
Attached is a patch with my stab at file upload capabilities for TBNL. :)
Hi Michael!
Thanks for providing this! I don't think I'll find the time to review it and release a new version this week, so I encourage other users of TBNL to apply the patch and try on their own. (And please report your results to the mailing list.)
If you haven't heard back from me until next tuesday or so please remind me... :)
Thanks again, Edi.
On Wed, 27 Oct 2004 23:04:17 +0200, Michael Weber michaelw+tbnl@foldr.org wrote:
Attached is a patch with my stab at file upload capabilities for TBNL. :)
Thanks again and sorry for the delay. I've uploaded a new version which implements file upload capabilities based on your suggestions and code. I've changed it such that it doesn't load the uploaded files into RAM but rather streams them to temporary files. The little test suite now also has a file upload page.
Here's the Changelog entry
Version 0.3.0 2004-11-09 Initial support for multipart/form-data (thanks to Michael Weber and Janis Dzerins) Fixed bug in CREATE-STATIC-FILE-DISPATCHER-AND-HANDLER (caught by Bill Clementson)
Note that the new download link is
http://weitz.de/files/tbnl.tar.gz
(it's .tar.gz instead of .tgz).
Some of you might also be interested in Bill Clementson's blog entry about using TBNL on Windows:
http://home.comcast.net/~bc19191/blog/041105.html
I agree that it probably wouldn't be a good idea to use this as a production environment but it might be handy for development and/or demoing.
The new code has been tested with CMUCL 19a on Linux, Allegro 7.0 pro on Linux, Allegro 6.2 trial on Windows, and LispWorks 4.3.7 pro on Windows.
Cheers, Edi.