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

The request body should be encoded according to the request header #1012

Merged
merged 1 commit into from
Feb 8, 2020
Merged

The request body should be encoded according to the request header #1012

merged 1 commit into from
Feb 8, 2020

Conversation

BenVercammen
Copy link

Currently the setupBody() method in the ProviderClient class does not set a contentType. This results in the StringEntity() constructor to use the HTTP.DEF_CONTENT_CHARSET, which in turn resolves to Consts.ISO_8859_1.

This is a problem when you have a UTF-8 encoded pact.json file with special characters. The request that is being sent by the mock consumer, will read the UTF-8 encoded body (from the pact file) as ISO-8859-1, thus messing up any special characters it contains.

I've also got a very basic Spring Boot project set up to show the problem at https://github.com/BenVercammen/pact-jvm-provider-encoding-issue.git
(make sure the pact files are properly encoded, probably will check out in default encoding)

Disclaimer: I'm not familiar with kotlin or groovy...

@BenVercammen BenVercammen requested a review from uglyog February 5, 2020 10:44
@uglyog
Copy link
Member

uglyog commented Feb 8, 2020

Thanks for the PR!

@uglyog uglyog merged commit e897b8f into pact-foundation:master Feb 8, 2020
@BenVercammen BenVercammen deleted the provider-client-request-body-encoding branch February 10, 2020 08:11
@uglyog
Copy link
Member

uglyog commented Feb 22, 2020

4.0.6 has been released with this fix

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

Successfully merging this pull request may close these issues.

None yet

2 participants