[gambit-list] cgi in Gambit

Vok Vojwo ceving at gmail.com
Wed Dec 14 04:55:47 EST 2011

2011/12/13 Eduardo Costa <edu500ac at yahoo.com>
> Therefore, I decided to switch to Gambit, Bigloo or SBCL.

Maybe you should consider also Chicken: www.call-cc.org. Chicken has
many modules. Some are buggy but most work right out of the box. Last
week I had to write a HTTP server which acts as a XML transformer
between a client talking HTTP and a server talking HTTPS. It took me
less than a week to finish the daemon with all the Unix goodies:
syslog, fork, signals etc. Calling continuations in signal handlers is
really funny. I have no idea how this works but it seems to.

> Here is the script (that works in my machine):
> #! ./gsi-script -:d-
> (display "Content-type: text/html")
> (newline)
> (newline)
> (display
> "<html>
>   <body>
>    <h1>Hello from Gambit</h1>
>   </body>
> </html>" )
> (newline)
> The server encountered an internal error or misconfiguration and was unable to complete your request.

HTTP headers must be delimited with CRNL. The same applies to CGI
programs. You should not rely on newline, because it is likely that it
does different things on different systems. This would be a valid
response on every machine:

(display "Content-type: text/html\r\n")
(display "\r\n")
(display "<html><body>hello</body></html>")

But if you need the best CGI support you should probably use Perl instead:

More information about the Gambit-list mailing list