Commit 14b64fef authored by Slawomir Jasinski's avatar Slawomir Jasinski

fix #127

fixes issue with Status header coming from php-fpm 5.5 different then regular "HTTP/1.1 200 OK".
If server returns  Status code - "200" will be handled properly instead "throwing runtime error: index out of range"
parent 01aca02e
...@@ -375,12 +375,21 @@ func (c *FCGIClient) Request(p map[string]string, req io.Reader) (resp *http.Res ...@@ -375,12 +375,21 @@ func (c *FCGIClient) Request(p map[string]string, req io.Reader) (resp *http.Res
resp.Header = http.Header(mimeHeader) resp.Header = http.Header(mimeHeader)
if resp.Header.Get("Status") != "" { if resp.Header.Get("Status") != "" {
// check if Status is long enought to split
if strings.Count(resp.Header.Get("Status"), " ") > 0 {
statusParts := strings.SplitN(resp.Header.Get("Status"), " ", 2) statusParts := strings.SplitN(resp.Header.Get("Status"), " ", 2)
resp.StatusCode, err = strconv.Atoi(statusParts[0]) resp.StatusCode, err = strconv.Atoi(statusParts[0])
resp.Status = statusParts[1]
resp.Status = statusParts[1]
} else {
resp.StatusCode, err = strconv.Atoi(resp.Header.Get("Status"))
}
if err != nil { if err != nil {
return return
} }
resp.Status = statusParts[1]
} else { } else {
resp.StatusCode = http.StatusOK resp.StatusCode = http.StatusOK
} }
......
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