import "github.com/mholt/caddy/caddyhttp/fastcgi"
Package fastcgi has middleware that acts as a FastCGI client. Requests that get forwarded to FastCGI stop the middleware execution chain. The most common use for this package is to serve PHP websites via php-fpm.
fastcgi.go fcgiclient.go setup.go
const ( // BeginRequest is the begin request flag. BeginRequest uint8 = iota + 1 // AbortRequest is the abort request flag. AbortRequest // EndRequest is the end request flag. EndRequest // Params is the parameters flag. Params // Stdin is the standard input flag. Stdin // Stdout is the standard output flag. Stdout // Stderr is the standard error flag. Stderr // Data is the data flag. Data // GetValues is the get values flag. GetValues // GetValuesResult is the get values result flag. GetValuesResult // UnknownType is the unknown type flag. UnknownType // MaxType is the maximum type flag. MaxType = UnknownType )
const ( // Responder is the responder flag. Responder uint8 = iota + 1 // Authorizer is the authorizer flag. Authorizer // Filter is the filter flag. Filter )
const ( // RequestComplete is the completed request flag. RequestComplete uint8 = iota // CantMultiplexConns is the multiplexed connections flag. CantMultiplexConns // Overloaded is the overloaded flag. Overloaded // UnknownRole is the unknown role flag. UnknownRole )
const ( // MaxConns is the maximum connections flag. MaxConns string = "MAX_CONNS" // MaxRequests is the maximum requests flag. MaxRequests string = "MAX_REQS" // MultiplexConns is the multiplex connections flag. MultiplexConns string = "MPXS_CONNS" )
FCGIHeaderLen describes header length.
FCGIKeepConn describes keep connection mode.
FCGIListenSockFileno describes listen socket file number.
FCGINullRequestID describes the null request ID.
Version1 describes the version.
var ( // ErrIndexMissingSplit describes an index configuration error. ErrIndexMissingSplit = errors.New("configured index file(s) must include split value") )
type FCGIClient struct {
// contains filtered or unexported fields
}
FCGIClient implements a FastCGI client, which is a standard for interfacing external applications with Web servers.
func Dial(network, address string) (fcgi *FCGIClient, err error)
Dial connects to the fcgi responder at the specified network address, using default net.Dialer. See func net.Dial for a description of the network and address parameters.
DialContext is like Dial but passes ctx to dialer.Dial.
func DialWithDialerContext(ctx context.Context, network, address string, dialer net.Dialer) (fcgi *FCGIClient, err error)
DialWithDialerContext connects to the fcgi responder at the specified network address, using custom net.Dialer and a context. See func net.Dial for a description of the network and address parameters.
func (c *FCGIClient) Close()
Close closes fcgi connection
Do made the request and returns a io.Reader that translates the data read from fcgi responder out of fcgi packet before returning it.
func (c *FCGIClient) Get(p map[string]string, body io.Reader, l int64) (resp *http.Response, err error)
Get issues a GET request to the fcgi responder.
Head issues a HEAD request to the fcgi responder.
Options issues an OPTIONS request to the fcgi responder.
func (c *FCGIClient) Post(p map[string]string, method string, bodyType string, body io.Reader, l int64) (resp *http.Response, err error)
Post issues a POST request to the fcgi responder. with request body in the format that bodyType specified
func (c *FCGIClient) PostFile(p map[string]string, data url.Values, file map[string]string) (resp *http.Response, err error)
PostFile issues a POST to the fcgi responder in multipart(RFC 2046) standard, with form as a string key to a list values (url.Values), and/or with file as a string key to a list file path.
func (c *FCGIClient) PostForm(p map[string]string, data url.Values) (resp *http.Response, err error)
PostForm issues a POST to the fcgi responder, with form as a string key to a list values (url.Values)
Request returns a HTTP Response with Header and Body from fcgi responder
func (c *FCGIClient) SetReadTimeout(t time.Duration) error
SetReadTimeout sets the read timeout for future calls that read from the fcgi responder. A zero value for t means no timeout will be set.
func (c *FCGIClient) SetSendTimeout(t time.Duration) error
SetSendTimeout sets the read timeout for future calls that send data to the fcgi responder. A zero value for t means no timeout will be set.
type Handler struct { Next httpserver.Handler Rules []Rule Root string FileSys http.FileSystem // These are sent to CGI scripts in env variables SoftwareName string SoftwareVersion string ServerName string ServerPort string }
Handler is a middleware type that can handle requests as a FastCGI client.
ServeHTTP satisfies the httpserver.Handler interface.
LogError is a non fatal error that allows requests to go through.
Error satisfies error interface.
type Rule struct { // The base path to match. Required. Path string // Always process files with this extension with fastcgi. Ext string // Use this directory as the fastcgi root directory. Defaults to the root // directory of the parent virtual host. Root string // The path in the URL will be split into two, with the first piece ending // with the value of SplitPath. The first piece will be assumed as the // actual resource (CGI script) name, and the second piece will be set to // PATH_INFO for the CGI script to use. SplitPath string // If the URL ends with '/' (which indicates a directory), these index // files will be tried instead. IndexFiles []string // Environment Variables EnvVars [][2]string // Ignored paths IgnoredSubPaths []string // The duration used to set a deadline when connecting to an upstream. ConnectTimeout time.Duration // The duration used to set a deadline when reading from the FastCGI server. ReadTimeout time.Duration // The duration used to set a deadline when sending to the FastCGI server. SendTimeout time.Duration // contains filtered or unexported fields }
Rule represents a FastCGI handling rule. It is parsed from the fastcgi directive in the Caddyfile, see setup.go.
AllowedPath checks if requestPath is not an ignored path.
Package fastcgi imports 26 packages (graph) and is imported by 108 packages. Updated 2019-11-23. Refresh now. Tools for package owners.