Dont parse errors as JSON unless Content-Type is set to JSON
Client attempts to parse the body of every error it receives as JSON regardless of the content-type. This commit rectifies by only parsing he error body as JSON if the Content-Type header is set to either "application/json" or "application/vnd.api+json". Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
This commit is contained in:
parent
4f7424c8eb
commit
45b7b9cec3
4 changed files with 70 additions and 24 deletions
|
@ -86,6 +86,7 @@ func TestUploadReadFrom(t *testing.T) {
|
|||
},
|
||||
Response: testutil.Response{
|
||||
StatusCode: http.StatusBadRequest,
|
||||
Headers: http.Header{"Content-Type": []string{"application/json; charset=utf-8"}},
|
||||
Body: []byte(`
|
||||
{ "errors":
|
||||
[
|
||||
|
@ -107,6 +108,7 @@ func TestUploadReadFrom(t *testing.T) {
|
|||
},
|
||||
Response: testutil.Response{
|
||||
StatusCode: http.StatusBadRequest,
|
||||
Headers: http.Header{"Content-Type": []string{"application/json"}},
|
||||
Body: []byte("something bad happened"),
|
||||
},
|
||||
},
|
||||
|
@ -372,6 +374,7 @@ func TestUploadWrite(t *testing.T) {
|
|||
},
|
||||
Response: testutil.Response{
|
||||
StatusCode: http.StatusBadRequest,
|
||||
Headers: http.Header{"Content-Type": []string{"application/json; charset=utf-8"}},
|
||||
Body: []byte(`
|
||||
{ "errors":
|
||||
[
|
||||
|
@ -393,6 +396,7 @@ func TestUploadWrite(t *testing.T) {
|
|||
},
|
||||
Response: testutil.Response{
|
||||
StatusCode: http.StatusBadRequest,
|
||||
Headers: http.Header{"Content-Type": []string{"application/json"}},
|
||||
Body: []byte("something bad happened"),
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue