Closed Philonous closed 6 years ago
@Philonous As I understand it application/json; charset=utf-8
is non-standard. See also https://github.com/hspec/hspec-wai/pull/40 and elsewhere on the Internet.
@Philonous if you want to test your current behavior, you can do this with:
get "/users" `shouldRespondWith` [json|[{"name":"bob"}]|] {matchHeaders = ["Content-Type" <:> "application/json; charset=utf-8"]}
@jkarni any opinion on this. Have you had a discussion on what the right thing for servant
is before?
Servant seems to implement it on purpose to appease other clients (see https://github.com/haskell-servant/servant/issues/849).
Also, the JSON rfc remarks that although it isn't defined, it should be ignored by compliant recipients:
Note: No "charset" parameter is defined for this registration. Adding one really has no effect on compliant recipients.
So I think this should be fixed here and have implemented a patch: https://github.com/hspec/hspec-wai/pull/47
I added a lengthy source code comment in https://github.com/hspec/hspec-wai/commit/791dcbb48dff41735b53758d988b8754ad7dc49b that elaborates my view on this matter.
Fixed.
Thanks :)
I'm trying to test a REST api written in servant. To that end I have a test like this:
That test fails with
The actual header is compatible with the required one, so this shouldn't fail.