Re: How to simple exit in CGI?
Jean Louis <[email protected]> Tue, 28 Mar 2017 19:39:37 +0300
| Newsgroups | gmane.lisp.clisp.general |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Mar 28, 2017 at 03:21:15PM +0000, [email protected] wrote: > >>On Tue, Mar 28, 2017 at 02:32:48AM +0200, Pascal Bourguignon wrote: > > You should print out HTTP headers. You can use them to report some status. > >Thank you. Sure, I am sending headers when necessary. If not necessary, > >in case of direct call to CGI, I like to send the redirect. > > Please explain "in case of direct call to CGI"? > IMHO, you should learn the HTTP protocol, either version 1.0 (1996) > https://tools.ietf.org/html/rfc1945 > or 1.1 (1999) or perhaps HTTP/2 (2015). > There's no "when necessary". You MUST always return headers. It is ALWAYS necessary. > (Except with HTTP "0.9", 26 years ago). Alright, so I wish to print the redirect in case of no input. Yet, it never comes to the redirect line. > > (query (or (getenv "QUERY_STRING") > Please explain your setup. Obviously CLISP is not the web-server front end > (otherwise there would be no such environment variables). > What is your web-server (Apache?) thttpd yet it does not matter, I tried with other web servers, it is no any fault in the web server. wget -O /dev/shm/test "http://localhost/test.cgi"; less /dev/shm/test --2017-03-28 19:33:48-- http://localhost/test.cgi Resolving localhost... 127.0.0.1 Connecting to localhost|127.0.0.1|:80... connected. HTTP request sent, awaiting response... that line is waiting for about 45 seconds and answer with nothing. The program is down below, and it is saved as executable memory image. If I run it with: wget -O /dev/shm/test "http://localhost/test.cgi?anything"; less /dev/shm/test then I immediately get the redirect to other page. (setf custom:*ansi* t) (defun main nil (let ((url "http://localhost") (query (or (getenv "QUERY_STRING") (alexandria.0.dev:read-stream-content-into-string *standard-input*)))) (format t "Status: 302 Found~%Location: ~a~%~%" url) ;; XXX line (finish-output) (exit 0))) ;; (main) > and how is it configured to run CLISP (mod_fcgi for FastCGI)? It is just running the executable memory image test.cgi > >yet if I don't send any parameters, I get displayed: > >*** - Ctrl-C: User break > >Break 1 [1]> > >I would like to understand what is happening. > > Me too, yet your configuration is completely unclear to me. When I > ran CLISP behind Apache many years ago, I'd never see a ^C in any > Apache log, nor a command prompt. How is CLISP started in your > setup? Just as you see the above small program, that is the one, and it is saved as executable memory image test.cgi -- and I am using CLISP development version. If I am not sending anything, the XXX line above never executes, so CLISP is waiting and get Ctrl-C probably by web server who interrupts the connection. Thank you. If you know the anwer what I am doing wrong that the line with (format t "Status 302... never comes to execution, without parameters, let me know. 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