corgi is a CGI server. [![free of syn](https://img.shields.io/badge/free%20of-syn-hotpink)](https://github.com/fasterthanlime/free-of-syn) corgi listens on port 26744 by default. `/etc/corgi.conf` ``` Server Port 26744 StatsDb /var/corgi/stats.db Script Match Regex Script Environment HTTP_HOST ENV_KEY ``` See [corgi.conf](corgi.conf) for the configuration I use with my cgit instance. Scripts are tried in order, looking for one that matches. If none match, the first script is ran. Sets the following environmental variables for the CGI script, many following [RFC 3875][rfc]: - **`GATEWAY_INTERFACE`** to the fixed value `CGI/1.1` - **`PATH_INFO`** to the HTTP path the client requested - **`QUERY_STRING`** to the query part of the URI - **`REMOTE_ADDR`** is the `Forwarded-For` header, maybe prefixed with an `X-`, or the client address if that header is not set - **`REQUEST_METHOD`** to the HTTP request method - **`SCRIPT_NAME`** is set to the path specified in the config - **`SERVER_NAME`** is set to the HTTP host header - **`SERVER_PORT`** is the port that corgi is running on - **`SERVER_PROTOCOL`** is the HTTP version string that the request came in on - **`SERVER_SOFTWARE`** is `corgi/1.0` where `1.0` is the current version number Additionally, corgi will set environment variables for the HTTP request headers. They will be uppercased and hyphens replaced with underscores. Any environmental variable may be overridden if it is set in the configuration file, except the `CONTENT_LENGTH` envar. [rfc]: https://datatracker.ietf.org/doc/html/rfc3875 corgi has a cgi module system as an alternate for spawning a new process on every request. it creates a new thread, loads a dynamic library into it, and executes functions from that library. since it's a function, corgi doesn't need to send all the data on standard input but can instead pass a cleaner, more structured struct with the headers and body still separate from one another. the module system is designed to, hopefully, allow more efficient cgi scripts than the conventional approach while still having the same flexibility. it has not yet been benchmarked. see [smalldog](smalldog/README.md) for more details on how it works.