File tree 1 file changed +4
-2
lines changed
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
10
10
"io"
11
11
"math"
12
12
"math/rand"
13
+ "mime"
13
14
"net/http"
14
15
"net/url"
15
16
"runtime"
@@ -488,7 +489,8 @@ func (cfg *RequestConfig) Execute() (err error) {
488
489
489
490
// If we are not json, return plaintext
490
491
contentType := res .Header .Get ("content-type" )
491
- isJSON := strings .Contains (contentType , "application/json" ) || strings .Contains (contentType , "application/vnd.api+json" )
492
+ mediaType , _ , _ := mime .ParseMediaType (contentType )
493
+ isJSON := strings .Contains (mediaType , "application/json" ) || strings .HasSuffix (mediaType , "+json" )
492
494
if ! isJSON {
493
495
switch dst := cfg .ResponseBodyInto .(type ) {
494
496
case * string :
@@ -499,7 +501,7 @@ func (cfg *RequestConfig) Execute() (err error) {
499
501
case * []byte :
500
502
* dst = contents
501
503
default :
502
- return fmt .Errorf ("expected destination type of 'string' or '[]byte' for responses with content-type that is not 'application/json'" )
504
+ return fmt .Errorf ("expected destination type of 'string' or '[]byte' for responses with content-type '%s' that is not 'application/json'" , contentType )
503
505
}
504
506
return nil
505
507
}
You can’t perform that action at this time.
0 commit comments