You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Forces a header check for "Content-Type", "application/json"
I am testing a client that sends "content-type" with lower case C and T so this will never match
One solution could be to document the JSON method as adding a header and add a new method JSONBody
// JSON defines the JSON body to match based on a given structure, and adds a matcher for content type
func (r *Request) JSON(data interface{}) *Request {
if r.Header.Get("Content-Type") == "" {
r.Header.Set("Content-Type", "application/json")
}
return r.JSONBody(data)
}
// JSON defines the JSON body to match based on a given structure
func (r *Request) JSONBody(data interface{}) *Request {
r.BodyBuffer, r.Error = readAndDecode(data, "json")
return r
}
The text was updated successfully, but these errors were encountered:
cameronbraid
changed the title
Using .JSON forces a header match
Using .JSON forces a header match which isn't always wanted
Feb 6, 2021
I tried to mock AWS SDK for Golang (aws-sdk-go/1.42.39) and noticed this problem. AWS is sending Content-Type: application/x-amz-json-1.1. I would separate totally MatchHeader from the body matching.
Forces a header check for "Content-Type", "application/json"
I am testing a client that sends "content-type" with lower case
C
andT
so this will never matchOne solution could be to document the JSON method as adding a header and add a new method JSONBody
The text was updated successfully, but these errors were encountered: