Dropwizard Environment class unwantedly encodes Jersey Client request body to format other than UTF.

StackOverflow https://stackoverflow.com/questions/23568668

  •  19-07-2023
  •  | 
  •  

Question

When a Jersey client is created via the call below I am able to send request to my Mock Server with the request body encoded in a UTF format.

Client client = Client.create()

I initially thought it was the way i was setting the headers in the WebResource but I've now isolated the problem to lie someone in Dropwizard's Environment class. If i create my client with the following below then when i post my json its get encoded to a non UTF format.

Client client =  new JerseyClientBuilder().using(Environment).build();
Was it helpful?

Solution

Try disabling gzip when creating the jersey client:

JerseyClientConfiguration jerseyConfig = new JerseyClientConfiguration(); jerseyConfig.setGzipEnabled(false);

final Client httpClient = new JerseyClientBuilder().using(jerseyConfig).using(environment).build();

This solved the problem for me, hope it helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top