mirror of
https://github.com/status-im/consul.git
synced 2025-01-11 06:16:08 +00:00
Ensure we write json header before writing bytes
In net/http once we've issued a Write() the response is sent over the wire including the header! The tests didn't catch this because I used a net/http/httptest.RequestRecorder which doesn't follow those semantics.
This commit is contained in:
parent
484587f809
commit
3506b38a40
@ -124,8 +124,8 @@ func (s *HTTPServer) wrap(handler func(resp http.ResponseWriter, req *http.Reque
|
|||||||
if err = enc.Encode(obj); err != nil {
|
if err = enc.Encode(obj); err != nil {
|
||||||
goto HAS_ERR
|
goto HAS_ERR
|
||||||
}
|
}
|
||||||
resp.Write(buf.Bytes())
|
|
||||||
resp.Header().Set("Content-Type", "application/json")
|
resp.Header().Set("Content-Type", "application/json")
|
||||||
|
resp.Write(buf.Bytes())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return f
|
return f
|
||||||
|
Loading…
x
Reference in New Issue
Block a user