Writing a CGI script for Molly Brown and why <CR><LF> is so important

2021-02-24

This Gemini capsule is currently powered by Agate on the default port of 1965. I am also running Molly Brown, a Gemini server, on port 7070. Molly Brown can also do server side scripts. The random quote link on the index page is powered by a CGI script.

Here is a portion of the script:

I spent hours trying to take this script that is on my Gopher server and switching it to the server running Molly Brown. I am embarrassed to admit. Here is what I missed and why it is important.

Here is the Gemini Specification that is important:

Taken from gemini://gemini.circumlunar.space/docs/specification.gmi

This is how I originally wrote my code:

I added the response header but did not terminate that line correctly. The script ran correctly in bash. It ran on the Gemini server but never displayed anything but returned a status code of 20. By not terminating the response header with a carriage return and a line feed the script did not display the rest of the page in Gemini. Once I added the carriage return and the line feed the script ran as intended.

My mistake shows the importance of paying attention to details.

..

Proxied content from gemini://frrobert.net/log/wriingacgiscript.gmi

Gemini request details:

Original URL
gemini://frrobert.net/log/wriingacgiscript.gmi
Status code
Success
Meta
text/gemini
Proxied by
kineto

Be advised that no attempt was made to verify the remote SSL certificate.