Re: How to simple exit in CGI?

Jean Louis <[email protected]> Fri, 31 Mar 2017 01:55:45 +0300
Newsgroups gmane.lisp.clisp.general
Message-ID <[email protected]>
On Thu, Mar 30, 2017 at 10:10:48PM +0200, Pascal Bourguignon wrote:
> Neither using LISTEN or directly READ-SEQUENCE are good solutions.
> Either one will work only by chance.

I guess that is deeper foundation of how it works. On my side it works
now well, so it will work in practice.

> LISTEN in particular will fail, if for whatever reason, the web
> server didn’t start writing the PUT data or POST parameters to the
> CGI pipe, when the CGI calls LISTEN.  I guess the same is true with
> READ-SEQUENCE: it won’t read an end-of-file if the web server
> doesn’t close that pipe.

OK, maybe, I don't know, I cannot say. I just test it on 2-3
webservers, those I use also remotely, if it works locally, it works
remotely, then I leave it working for years.

> And let me you ask the question: what reason does the web server
> have to close that pipe if it didn’t have to write anything to it,
> because it was a GET request?
> 
> The correct solution, as always, is to read the documentation,
> specifically, the RFC 3875 <https://tools.ietf.org/html/rfc3875>

> Or you may browse the Wikipedia summary, and find out that the CGI
> specifies that the environment variable REQUEST_METHOD will indicate
> whether it’s a GET, a PUT, a POST or whatever else.  You must test
> this before trying to read stdin!

> 
> 
> (defun main (&optional (arguments *args*))
>   (let ((method (getenv "REQUEST_METHOD")))
>     (cond ((or (string= method "PUT")
>                (string= method "POST"))

Thank you.

I have just shown the sample, in reality I am testing for QUERY_STRING
to get the GET parameters, if none, I test for *standard-input*, and
later for certain parameters, if they are missing, it goes to error
handling.

Jean

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
clisp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-list