Thanks a lot, that works perfectly.

By the way, is there a "best" way to parse multipart-form data? I tried with a horrible mix of read-line and read-char, and lost count pretty quickly.

Best,

Nathaniel

On Sam, Aug 9, 2014 at 9:21 , Peter Bex <peter....@xs4all.nl> wrote:
On Sat, Aug 09, 2014 at 05:40:31PM +0002, Nathaniel Rudavsky-Brody wrote:
 Hello,
In an Awful web app, I'm trying to read an image posted as raw data to the server, since it seems multipart/form-data isn't supported. (Is that right?) But I get the feeling I'm missing something regarding ports and requests... I *think* my basic question is, how do I know the request is finished?

It depends a bit on the type of request; if it's using chunked encoding,
the request-port you get is delimited, so you can just read until EOF.
Otherwise, you'll have to check the request's content-length header.

The nice bit about this is that if the client uses chunked encoding,
there will be no content-length header.  So either you read until
content-length is hit, or until EOF.

With JSON objects this wasn't a problem, using Medea: >(read-json (request-port (current-request)) >consume-trailing-whitespace: #f)

The reason you didn't run into problems here is that JSON objects
are self-delimited.  They always look like {...} or [...].  However,
if some library accidentally put some trailing whitespace in there you
would probably run into trouble upon reading the next request, when the
connection is keepalive.

Cheers,
Peter
--
http://www.more-magic.net
_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to