[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] reading file from post request
From: |
Peter Bex |
Subject: |
Re: [Chicken-users] reading file from post request |
Date: |
Sat, 9 Aug 2014 21:21:42 +0200 |
User-agent: |
Mutt/1.4.2.3i |
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
- Re: [Chicken-users] Wiki design, Arthur Maciel, 2014/08/08
- Re: [Chicken-users] Wiki design, Arthur Maciel, 2014/08/12
- Re: [Chicken-users] Wiki design, Mario Domenech Goulart, 2014/08/13
- Re: [Chicken-users] Wiki design, Arthur Maciel, 2014/08/13
- Re: [Chicken-users] Wiki design, Yaroslav Tsarko, 2014/08/19