Commit Diff


commit - 0ed56567950c521041674b3e255147b6d6bea03e
commit + 92e66347ed2971e811170559eb8865e0db0a5d3e
blob - 6e0de5d5bcafdc475c4528e12396eb3484e638d8
blob + b8b11de58e4b0534f268579b10c245dbd179914b
--- README.md
+++ README.md
@@ -6,18 +6,18 @@
 # SYNOPSIS
 
 **gmid**
-\[**-hx**]
+\[**-h**]
 \[**-c** *cert.pem*]
 \[**-d** *docs*]
 \[**-k** *key.pem*]
-\[**-l** *access.log*]
+\[**-l** *logfile*]
+\[**-x** *cgi-bin*]
 
 # DESCRIPTION
 
 **gmid**
-is a very simple and minimal gemini server.
-It only supports serving static content, and strive to be as simple as
-possible.
+is a very simple and minimal gemini server that can serve static files
+and execute CGI scripts.
 
 **gmid**
 will strip any sequence of
@@ -27,7 +27,7 @@ or trailing
 in the requests made by clients, so it's impossible to serve content
 outside the
 *docs*
-directory by mistake, and will also refuse to follow symlink.
+directory by mistake, and will also refuse to follow symlinks.
 Furthermore, on
 OpenBSD,
 pledge(2)
@@ -35,15 +35,15 @@ and
 unveil(2)
 are used to ensure that
 **gmid**
-dosen't do anything else than read files from the given directory and
-accept network connections.
+dosen't do anything else than read files from the given directory,
+accept network connections and, optionally, execute CGI scripts.
 
 It should be noted that
 **gmid**
 is very simple in its implementation, and so it may not be appropriate
-for serving site with lots of users.
-After all, the code is single threaded and use a single process
-(multiple requests are handled concurrently thanks to async I/O.)
+for serving sites with lots of users.
+After all, the code is single threaded and use a single process,
+although it can handle multiple requests concurrently.
 
 If a user request path is a directory,
 **gmid**
@@ -63,7 +63,8 @@ The options are as follows:
 
 > The root directory to serve.
 > **gmid**
-> won't serve any file that is outside that directory.
+> won't serve any file that is outside that directory, by default
+> *docs*.
 
 **-h**
 
@@ -74,7 +75,7 @@ The options are as follows:
 > The key for the certificate, by default is
 > *key.pem*.
 
-**-l** *access.log*
+**-l** *logfile*
 
 > log to the given file instead of the standard error.
 
@@ -88,6 +89,40 @@ The options are as follows:
 When CGI scripts are enabled for a directory, a request for an
 executable file will execute it and fed its output to the client.
 
+The CGI scripts will inherit the environment from
+**gmid**
+with these additional variables set:
+
+`SERVER_SOFTWARE`
+
+> "gmid"
+
+`SERVER_PROTOCOL`
+
+> "gemini"
+
+`SERVER_PORT`
+
+> "1965"
+
+`PATH_INFO`
+
+> the request path
+
+`PATH_TRANSLATED`
+
+> the full path: the concatenation of the document root and the request
+> path
+
+`QUERY_STRING`
+
+> the query string if present in the request URL, otherwise it
+> won't be set.
+
+`REMOTE_ADDR`
+
+> the IP address of the client in dot notation
+
 # EXAMPLES
 
 To quickly getting started
@@ -102,21 +137,21 @@ To quickly getting started
 	EOF
 	$ gmid -c cert.pem -k key.pem -d docs
 
-now you can visit gemini://localhost/ with your preferred gemini
+Now you can visit gemini://localhost/ with your preferred gemini
 client.
 
 To add some CGI scripts, assuming a setup similar to the previous
-example, one can
+example, you can
 
 	$ mkdir docs/cgi-bin
 	$ cat <<EOF > docs/cgi-bin/hello-world
 	#!/bin/sh
-	printf "20 text/plain0
+	printf "20 text/plain\r\n"
 	echo "hello world!"
 	EOF
-	$ gmid -d docs -x cgi-bin
+	$ gmid -x cgi-bin
 
-note that the argument to the
+Note that the argument to the
 **-x**
 option is
 *cgi-bin*