HEAD requests have no body, only HTTP response code, so we need to act accordingly

This commit is contained in:
Marin Bek 2014-11-11 15:37:07 +01:00
parent f8e5a2a433
commit e5d37bf945

12
goes.go
View File

@ -345,10 +345,14 @@ func (req *Request) Run() (Response, error) {
} }
esResp := new(Response) esResp := new(Response)
err = json.Unmarshal(body, &esResp) if req.method == "HEAD" {
if err != nil { esResp.Status = uint64(resp.StatusCode)
return Response{}, err } else {
} err = json.Unmarshal(body, &esResp)
if err != nil {
return Response{}, err
}
}
if req.api == "_bulk" && esResp.Errors { if req.api == "_bulk" && esResp.Errors {
for _, item := range esResp.Items { for _, item := range esResp.Items {