mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-23 19:10:03 +08:00
FastCGI: support for unix sockets.
This commit is contained in:
@ -58,7 +58,14 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Connect to FastCGI gateway
|
// Connect to FastCGI gateway
|
||||||
fcgi, err := Dial("tcp", rule.Address)
|
var fcgi *FCGIClient
|
||||||
|
|
||||||
|
// check if unix socket or tcp
|
||||||
|
if strings.HasPrefix(rule.Address, "/") {
|
||||||
|
fcgi, err = Dial("unix", rule.Address)
|
||||||
|
} else {
|
||||||
|
fcgi, err = Dial("tcp", rule.Address)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusBadGateway, err
|
return http.StatusBadGateway, err
|
||||||
}
|
}
|
||||||
@ -83,7 +90,10 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)
|
|||||||
default:
|
default:
|
||||||
return http.StatusMethodNotAllowed, nil
|
return http.StatusMethodNotAllowed, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if resp.Body != nil {
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
return http.StatusBadGateway, err
|
return http.StatusBadGateway, err
|
||||||
|
Reference in New Issue
Block a user