webmock icon indicating copy to clipboard operation
webmock copied to clipboard

`json_headers?` doesn't match when charset is specified in `Content-Type` header

Open cgrothaus opened this issue 4 years ago • 1 comments

When using the HTTP gem with a command like HTTP.post(url, json: { a: 1 }), the Content-Type-header is set to application/json; charset=UTF-8. This currently prevents me from using the RequestBodyDiff-method, as a check for json_headers? is made, which returns false if the content type isn't exactly application/json.

Specifying the charset in the content type should be allowed. So json_headers? should only check whether the content type starts with application/json, instead of requiring an exact match.

cgrothaus avatar Mar 09 '22 11:03 cgrothaus

There is an open PR #969 that fixes this.

cgrothaus avatar Mar 09 '22 11:03 cgrothaus