Skip to main content

Module fastcgi

Module fastcgi 

Source
Expand description

FastCGI client: PHP through php-fpm (18.21.0). FastCGI (18.21.0, #72): PHP through php-fpm, and any other FastCGI responder, without FrankenPHP or a second web server.

FastCgi is an Application: it maps a request onto a script under its root the way nginx’s and Caddy’s PHP setups do, sends it to the FastCGI server over TCP or a Unix socket, and turns the CGI response (RFC 3875 §6) back into a Response. Connections are kept alive and pooled. The config file’s type = "fastcgi" action builds one.

Which script runs for a request path P (with split_path = ".php"):

  1. P names a file under the root that isn’t a script → served as a static file (when a static handler is attached).
  2. P is a directory with an index script (index.php) → that script (/dir without the slash gets a redirect to /dir/).
  3. P contains .php and the part up to it is a script file → that script, the rest is PATH_INFO (/index.php/users/7).
  4. Otherwise the front controller (/index.php, the Laravel / Symfony / WordPress pattern), with REQUEST_URI unchanged.

A script must be a regular file under the root whose path ends in the split extension and has no dot-file segment, so /uploads/x.jpg/a.php never runs x.jpg (the old cgi.fix_pathinfo hole).

Structs§

FastCgi
FastCGI as an Application. See the module docs.
FastCgiConfig
Settings of a FastCgi handler.
Record
One record: type, request id and content.

Enums§

Address
Where the FastCGI server listens.

Functions§

decode_params
Decode name-value pairs; None on truncated or oversized input.
encode_params
Name-value pairs (§3.4): lengths < 128 in one byte, others in four with the top bit set.
encode_record
Append a record (content ≤ 65535 bytes) to out, padded to 8 bytes.
encode_stream
Append a stream (PARAMS, STDIN) as records, then its empty terminator.
params_from_map
Parse the FastCGI routes’ params table into pairs (for the config file).
parse_cgi_headers
Status, reason and headers of a CGI response header block. Status: sets the status; a Location: without one is a 302.
parse_records
Parse a buffer of records completely (for the fuzzer and tests): None on a malformed record.
read_record
Read one record; Ok(None) at a clean end of stream.