Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong cyrilic encoding #1783

Open
WhiteBite opened this issue Mar 27, 2024 · 6 comments
Open

Wrong cyrilic encoding #1783

WhiteBite opened this issue Mar 27, 2024 · 6 comments

Comments

@WhiteBite
Copy link

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?

@rholshausen
Copy link
Contributor

Try adding the correct charset to the content type header

@WhiteBite
Copy link
Author

WhiteBite commented Mar 28, 2024

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

@WhiteBite
Copy link
Author

image
image
bad encoding...

@WhiteBite
Copy link
Author

WhiteBite commented Mar 31, 2024

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

@rholshausen
Copy link
Contributor

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.

@WhiteBite
Copy link
Author

I am already checked this. All in UTF-8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants