Commit 4e94b85e authored by Abiola Ibrahim's avatar Abiola Ibrahim

FastCGI: support for unix sockets.

parent 6b3b04ff
......@@ -58,7 +58,14 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)
}
// 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 {
return http.StatusBadGateway, err
}
......@@ -83,7 +90,10 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)
default:
return http.StatusMethodNotAllowed, nil
}
defer resp.Body.Close()
if resp.Body != nil {
defer resp.Body.Close()
}
if err != nil && err != io.EOF {
return http.StatusBadGateway, err
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment