cookiesjerseyhttpclientjersey-clientspring-jersey

How to change the CookieSpec in Jersey Client?


I used Jersey Client in the project like this:

clientConfig.connectorProvider(new ApacheConnectorProvider());
clientConfig.register(MultiPartFeature.class);
client = ClientBuilder.newClient(clientConfig);

it actually use httpClient to do the job. but now I encountered the CookieSpec issue in this question: Fixing HttpClient warning “Invalid expires attribute” using fluent API. I need to change the CookieSpec but I cannot find where to change the config.


Solution

  • Maybe you can try to use the below solution:

    RequestConfig requestConfig = RequestConfig.custom()
                    .setCookieSpec(CookieSpecs.STANDARD).build();
            clientConfig.property(ApacheClientProperties.REQUEST_CONFIG, requestConfig);