[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] POST and GET request parameters from spiffy
From: |
Peter Bex |
Subject: |
Re: [Chicken-users] POST and GET request parameters from spiffy |
Date: |
Sun, 15 Nov 2009 12:45:51 +0100 |
User-agent: |
Mutt/1.4.2.3i |
On Sat, Nov 14, 2009 at 01:01:59PM +0100, Christian Kellermann wrote:
> * Michael Maul <address@hidden> [091113 22:38]:
> > Could someone describe how to access POS and GET parameters from inside
> > spiffy?
>
> (uri-query (request-uri (current-request)))) will get you the GET
> parameters as alist. I am not sure about POST. In chicken3 there
> used to be a convenience function in spiffy-utils.
The POST is not automatically extracted by Spiffy because I didn't want
to repeat the mistake in Chicken 3 where all POSTs were always read
straight into memory. This is a Bad Thing when you're uploading large
files or some smartass cracker is trying to break your app.
Anyway, the easy way to read the POST is this:
(form-urldecode (read-request-data (current-request)))
This will give you an alist of the form's data, if it was a regular
www/x-form-urlencoded form. If it was multipart, you will need to
replace form-urldecode (which is from the uri-common egg) with another
procedure. Currently I don't believe there is a decoder for multipart
forms yet, though. If you need this, you might want to take a look at
the old http-server-form-posts egg. Be warned that this should probably
be changed to writing a tempfile instead of loading the files into
memory.
Cheers,
Peter
--
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth