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_CONNS—1if the application multiplexes requests on a single connection,0otherwise. 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_INTERFACEwhen speaking CGI/1.1, which is what nginx and php-fpm hard-require. - HTTPS
HTTPS— set toonwhen the connection is TLS-protected. Read by many PHP frameworks for URL generation. Nginx convention.- HTTPS_
ON - Value of
HTTPSfor 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 ofPATH_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). Typically200.- REDIRECT_
STATUS_ OK - Value of
REDIRECT_STATUSmeaning “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_SCHEME—httporhttps. 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.