The main interface with the web request
Initializes it with command line arguments (for easy testing)
Initializes it using a CGI or CGI-like interface
Initializes the cgi from completely raw HTTP data. The ir must have a Socket source. *closeConnection will be set to true if you should close the connection after handling this request
Initializes it from raw HTTP request data. GenericMain uses this when you compile with -version=embedded_httpd.
the methods a request can be
Returns true if it is still possible to output headers
Clears a previously set cookie with the given name, path, and domain.
Flushes the buffers to the network, signifying that you are done. You should always call this explicitly when you are done outputting data.
Cleans up any temporary files. Do not use the object after calling this.
This gets a full url for the current request, including port, protocol, host, path, and query
Gets a session object associated with the cgi request. You can use different type throughout your application.
Adds a custom header. It should be the name: value, but without any line terminator. For example: header("X-My-Header: Some value"); Note you should use the specialized functions in this object if possible to avoid duplicates in the output.
Is the output already closed?
You can override this if your site base url isn't the same as the script name
you can override this function to somehow react to an upload in progress.
Gets a request variable as a specific type, or the default value of it isn't there or isn't convertible to the request type.
Very simple method to require a basic auth username and password. If the http request doesn't include the required credentials, it throws a HTTP 401 error, and an exception.
Very simple caching controls - setCache(false) means it will never be cached. Good for rapidly updated or sensitive sites. setCache(true) means it will always be cached for as long as possible. Best for static content. Use setResponseExpires and updateResponseExpires for more control
Sets an HTTP cookie, automatically encoding the data to the correct string. expiresIn is how many milliseconds in the future the cookie will expire. TIP: to make a cookie accessible from subdomains, set the domain to .yourdomain.com. Note setCookie() must be called *before* you write() any data to the output.
Sets the content type of the response, for example "text/html" (the default) for HTML, or "image/png" for a PNG image
Sets the Expires: http header. See also: updateResponseExpires, setPublicCaching The parameter is in unix_timestamp * 1000. Try setResponseExpires(getUTCtime() + SOME AMOUNT) for normal use. Note: the when parameter is different than setCookie's expire parameter.
Sets a cache-control max-age header for whenFromNow, in seconds.
Sets the location header, which the browser will redirect the user to automatically. Note setResponseLocation() must be called *before* you write() any data to the output. The optional important argument is used if it's a default suggestion rather than something to insist upon.
Sets the HTTP status of the response. For example, "404 File Not Found" or "500 Internal Server Error". It assumes "200 OK", and automatically changes to "302 Found" if you call setResponseLocation(). Note setResponseStatus() must be called *before* you write() any data to the output.
This is like setResponseExpires, but it can be called multiple times. The setting most in the past is the one kept. If you have multiple functions, they all might call updateResponseExpires about their own return value. The program output as a whole is as cacheable as the least cachable part in the chain. setCache(false) always overrides this - it is, by definition, the strictest anti-cache statement available. If your site outputs sensitive user data, you should probably call setCache(false) when you do, to ensure no other functions will cache the content, as it may be a privacy risk. Conversely, setting here overrides setCache(true), since any expiration date is in the past of infinity.
Writes the data to the output, flushing headers if they have not yet been sent.
This represents a file the user uploaded via a POST request.
Represents user uploaded files.
Here come the parsed request variables - the things that come close to PHP's _GET, _POST, etc. superglobals in content.
Set to true and use cgi.write(data, true); to send a gzipped response to browsers who can accept it
Set to true if and only if this was initialized with command line arguments
The Referer header from the request. (It is misspelled in the HTTP spec, and thus the actual request and cgi specs too, but I spelled the word correctly here because that's sane. The spec's misspelling is an implementation detail.) It contains the site url that referred the user to your program; the site that linked to you, or if you're serving images, the site that has you as an image. Also, if you're in an iframe, the referrer is the site that is framing you.
What follows is data gotten from the HTTP request. It is all fully immutable, partially because it logically is (your code doesn't change what the user requested...) and partially because I hate how bad programs in PHP change those superglobals to do all kinds of hard to follow ugliness. I don't want that to ever happen in D.