diff --git a/client.go b/client.go index 751e7b59..321a60fb 100644 --- a/client.go +++ b/client.go @@ -62,8 +62,8 @@ var ( jsonContentType = "application/json" formContentType = "application/x-www-form-urlencoded" - jsonCheck = regexp.MustCompile(`(?i:(application|text)/(json|.*\+json|json\-.*)(;|$))`) - xmlCheck = regexp.MustCompile(`(?i:(application|text)/(xml|.*\+xml)(;|$))`) + jsonCheck = regexp.MustCompile(`(?i:(application|text)/(.*json.*)(;|$))`) + xmlCheck = regexp.MustCompile(`(?i:(application|text)/(.*xml.*)(;|$))`) hdrUserAgentValue = "go-resty/" + Version + " (https://github.com/go-resty/resty)" bufPool = &sync.Pool{New: func() interface{} { return &bytes.Buffer{} }} diff --git a/util_test.go b/util_test.go index a78babfc..74cf4b1f 100644 --- a/util_test.go +++ b/util_test.go @@ -23,20 +23,18 @@ func TestIsJSONType(t *testing.T) { {"application/vnd.foo+json; charset=utf-8", true}, {"text/json", true}, - {"text/xml+json", true}, {"text/vnd.foo+json", true}, - {"application/foo-json", false}, - {"application/foo.json", false}, - {"application/vnd.foo-json", false}, - {"application/vnd.foo.json", false}, - {"application/json+xml", false}, - - {"text/foo-json", false}, - {"text/foo.json", false}, - {"text/vnd.foo-json", false}, - {"text/vnd.foo.json", false}, - {"text/json+xml", false}, + {"application/foo-json", true}, + {"application/foo.json", true}, + {"application/vnd.foo-json", true}, + {"application/vnd.foo.json", true}, + {"application/x-amz-json-1.1", true}, + + {"text/foo-json", true}, + {"text/foo.json", true}, + {"text/vnd.foo-json", true}, + {"text/vnd.foo.json", true}, } { result := IsJSONType(test.input) @@ -52,27 +50,23 @@ func TestIsXMLType(t *testing.T) { expect bool }{ {"application/xml", true}, - {"application/json+xml", true}, {"application/vnd.foo+xml", true}, {"application/xml; charset=utf-8", true}, {"application/vnd.foo+xml; charset=utf-8", true}, {"text/xml", true}, - {"text/json+xml", true}, {"text/vnd.foo+xml", true}, - {"application/foo-xml", false}, - {"application/foo.xml", false}, - {"application/vnd.foo-xml", false}, - {"application/vnd.foo.xml", false}, - {"application/xml+json", false}, - - {"text/foo-xml", false}, - {"text/foo.xml", false}, - {"text/vnd.foo-xml", false}, - {"text/vnd.foo.xml", false}, - {"text/xml+json", false}, + {"application/foo-xml", true}, + {"application/foo.xml", true}, + {"application/vnd.foo-xml", true}, + {"application/vnd.foo.xml", true}, + + {"text/foo-xml", true}, + {"text/foo.xml", true}, + {"text/vnd.foo-xml", true}, + {"text/vnd.foo.xml", true}, } { result := IsXMLType(test.input)