Open WhiteBite opened 7 months ago
Try adding the correct charset to the content type header
Try adding the correct charset to the content type header @rholshausen I don't want to add headers to the pact that aren't in real controllers. This is incorrect, add headers for tests. And I don't have any additional headers in production
bad encoding...
I think I found the mistake. In almost all examples, the header is either not specified or Content-type: application/json; charset=utf-8.
The problem is that spring considers Content-type: application/json; charset=utf-8 obsolete. And by default it writes the usual Content-type: application/json . And when I explicitly specify in tests that I expect Content-type: application/json, pact can't handle the encoding. I think this needs to be fixed.
I found some bad fixes. / 1) Add UTF-8 support to the Spring filter 2) Still write Content-type: application/json; charset=utf-8, despite the real answer. 3) Do not check headers
All options are bad and need to be discussed, I'm surprised no one has encountered this before
If there is no charset provided with the content type header, Pact-JVM will use the value returned by Charset.defaultCharset()
. Please note that this may not always be UTF-8, but is dependent on the file.encoding
system property. That could be UTF-16 or cp1252 on Windows.
I am already checked this. All in UTF-8
I have created a package in which DTO transfers from service 1 to service 2. Added application/json to the header. But it does not pass because when checking, it replaces Russian characters with other characters. what to do?