[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua + cgilua + lightttpd
- From: Petite Abeille <petite.abeille@...>
- Date: Mon, 5 Aug 2013 19:57:36 +0200
On Aug 5, 2013, at 1:04 PM, Henrique Gogó <firstname.lastname@example.org> wrote:
> How do I get "GET parameters" and POSTS, or request header using CGI
CGI is very simple… all you need is in the script environment (as per os.getenv).
The URL parameters are in QUERY_STRING. So os.getenv( 'QUERY_STRING' ). They are URL-encoded, so you need to decode them before using them. See example bellow.
For a POST, the parameters are in the request body. So you need to get the length of the content (os.getenv( "CONTENT_LENGTH" ) ), then read that much from io.stdin. Again, the parameters will be encoded ( 'application/x-www-form-urlencoded' usually, possibly 'multipart/form-data'). You will need to decode them as well.
Etc, etc, etc...
Here are some details about CGI:
The Common Gateway Interface (CGI) Version 1.1
And a little usage example.
Description: Binary data