This commit is contained in:
Brad Fitzpatrick 2011-01-05 08:08:45 -08:00
parent 176cf7d0aa
commit dda5a82dab
1 changed files with 4 additions and 1 deletions

View File

@ -86,9 +86,12 @@ func ReadResponse(r *bufio.Reader, requestMethod string) (resp *Response, err os
return nil, err return nil, err
} }
f := strings.Split(line, " ", 3) f := strings.Split(line, " ", 3)
if len(f) < 3 { if len(f) < 2 {
return nil, &badStringError{"malformed HTTP response", line} return nil, &badStringError{"malformed HTTP response", line}
} }
if len(f) == 2 {
f = append(f, f[1]) // Empty Reason-Phrase
}
resp.Status = f[1] + " " + f[2] resp.Status = f[1] + " " + f[2]
resp.StatusCode, err = strconv.Atoi(f[1]) resp.StatusCode, err = strconv.Atoi(f[1])
if err != nil { if err != nil {