Skip to main content

Module cgi

Module cgi 

Available on crate feature fastcgi only.
Expand description

CGI parameter name constants used in FastCGI FCGI_PARAMS and FCGI_GET_VALUES records.

FastCGI carries name-value pairs whose meaning is defined by the CGI specification (RFC 3875 §4) and a set of de-facto extensions popularised by nginx and php-fpm. Both are vendored under rama-fastcgi/specifications/.

Use these constants instead of Bytes::from_static(b"REQUEST_METHOD") literals: they’re zero-cost (each is a const Bytes backed by a &'static [u8]), they catch typos at compile time, and they keep the spec reference one click away in IDE hover-docs.

Examples:

use rama_fastcgi::proto::cgi;
use rama_fastcgi::FastCgiClientRequest;
use rama_core::bytes::Bytes;

let mut req = FastCgiClientRequest::new(vec![]);
req.push_param(cgi::REQUEST_METHOD, Bytes::from_static(b"GET"));
req.push_param(cgi::SCRIPT_FILENAME, "/var/www/index.php");

Constants§

AUTH_TYPE
AUTH_TYPE — the protocol-specific authentication scheme. RFC 3875 §4.1.1.
CONTENT_LENGTH
CONTENT_LENGTH — the size of the request body, in bytes. RFC 3875 §4.1.2.
CONTENT_TYPE
CONTENT_TYPE — the media type of the request body. RFC 3875 §4.1.3.
DOCUMENT_ROOT
DOCUMENT_ROOT — absolute filesystem path of the directory containing the script. Nginx convention; php-fpm reads it via $_SERVER.
DOCUMENT_URI
DOCUMENT_URI — the URL path that addressed the resource (after rewrites). Nginx convention.
FCGI_MAX_CONNS
FCGI_MAX_CONNS — max number of concurrent transport connections the application accepts. FastCGI spec §4.1.
FCGI_MAX_REQS
FCGI_MAX_REQS — max number of concurrent requests the application accepts. FastCGI spec §4.1.
FCGI_MPXS_CONNS
FCGI_MPXS_CONNS1 if the application multiplexes requests on a single connection, 0 otherwise. FastCGI spec §4.1.
GATEWAY_INTERFACE
GATEWAY_INTERFACE — the dialect of CGI being used (e.g. CGI/1.1). RFC 3875 §4.1.4.
GATEWAY_INTERFACE_CGI_1_1
Canonical value of GATEWAY_INTERFACE when speaking CGI/1.1, which is what nginx and php-fpm hard-require.
HTTPS
HTTPS — set to on when the connection is TLS-protected. Read by many PHP frameworks for URL generation. Nginx convention.
HTTPS_ON
Value of HTTPS for a TLS-protected request. Frameworks (Laravel, WordPress, …) read this for URL generation.
PATH_INFO
PATH_INFO — extra path information after the script identifier. RFC 3875 §4.1.5.
PATH_TRANSLATED
PATH_TRANSLATED — the filesystem-mapped form of PATH_INFO. RFC 3875 §4.1.6.
QUERY_STRING
QUERY_STRING — the URL-encoded query component. RFC 3875 §4.1.7.
REDIRECT_STATUS
REDIRECT_STATUS — required by php-fpm when PHP was built with --enable-force-cgi-redirect (the upstream default). Typically 200.
REDIRECT_STATUS_OK
Value of REDIRECT_STATUS meaning “no preceding redirect / safe to run”. php-fpm with --enable-force-cgi-redirect (the upstream default) refuses to dispatch when this isn’t set; "200" is the conventional value.
REMOTE_ADDR
REMOTE_ADDR — the network address of the client. RFC 3875 §4.1.8.
REMOTE_HOST
REMOTE_HOST — the fully-qualified hostname of the client, when known. RFC 3875 §4.1.9.
REMOTE_IDENT
REMOTE_IDENT — the RFC 1413 ident user, when available. RFC 3875 §4.1.10.
REMOTE_PORT
REMOTE_PORT — the TCP source port of the client. Nginx convention.
REMOTE_USER
REMOTE_USER — the authenticated user identity. RFC 3875 §4.1.11.
REQUEST_METHOD
REQUEST_METHOD — the HTTP method (e.g. GET, POST). RFC 3875 §4.1.12.
REQUEST_SCHEME
REQUEST_SCHEMEhttp or https. Nginx convention.
REQUEST_URI
REQUEST_URI — the raw URI (path + query) the server received, pre-rewrite. Nginx convention; frameworks like Laravel/Symfony read this for routing.
SCRIPT_FILENAME
SCRIPT_FILENAME — absolute filesystem path of the script (the front-controller). Required by php-fpm — it refuses to run without one. Not defined by RFC 3875.
SCRIPT_NAME
SCRIPT_NAME — the URL path component identifying the script. RFC 3875 §4.1.13.
SERVER_ADDR
SERVER_ADDR — the IP address the server bound to. Nginx convention.
SERVER_NAME
SERVER_NAME — the hostname/IP the server is using for self-reference. RFC 3875 §4.1.14.
SERVER_PORT
SERVER_PORT — the TCP port on which the request was received. RFC 3875 §4.1.15.
SERVER_PROTOCOL
SERVER_PROTOCOL — the name/version of the protocol carrying the request (HTTP/1.1, HTTP/2, …). RFC 3875 §4.1.16.
SERVER_SOFTWARE
SERVER_SOFTWARE — name and version of the gateway. RFC 3875 §4.1.17.