Go 1.10 omits Content-Type if server response has no body
https://tip.golang.org/doc/go1.10#net/http > The content-serving handlers also now omit the Content-Type header when serving zero-length content.pull/9208/head
parent
a0b2195d6b
commit
4f0c70591b
|
@ -534,7 +534,7 @@ func (c *client) Query(q Query) (*Response, error) {
|
|||
// like downstream serving a large file
|
||||
body, err := ioutil.ReadAll(io.LimitReader(resp.Body, 1024))
|
||||
if err != nil || len(body) == 0 {
|
||||
return nil, fmt.Errorf("expected json response, got %q, with status: %v", cType, resp.StatusCode)
|
||||
return nil, fmt.Errorf("expected json response, got empty body, with status: %v", resp.StatusCode)
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("expected json response, got %q, with status: %v and response body: %q", cType, resp.StatusCode, body)
|
||||
|
|
|
@ -240,7 +240,7 @@ func TestClientDownstream400_Query(t *testing.T) {
|
|||
query := Query{}
|
||||
_, err := c.Query(query)
|
||||
|
||||
expected := fmt.Sprintf(`expected json response, got "text/plain", with status: %v`, http.StatusForbidden)
|
||||
expected := fmt.Sprintf(`expected json response, got empty body, with status: %v`, http.StatusForbidden)
|
||||
if err.Error() != expected {
|
||||
t.Errorf("unexpected error. expected %v, actual %v", expected, err)
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ func TestClientDownstream400_ChunkedQuery(t *testing.T) {
|
|||
query := Query{Chunked: true}
|
||||
_, err := c.Query(query)
|
||||
|
||||
expected := fmt.Sprintf(`expected json response, got "text/plain", with status: %v`, http.StatusForbidden)
|
||||
expected := fmt.Sprintf(`expected json response, got empty body, with status: %v`, http.StatusForbidden)
|
||||
if err.Error() != expected {
|
||||
t.Errorf("unexpected error. expected %v, actual %v", expected, err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue