Selecting any CookieSpec deletes all cookies in the request.

I have a problem that I cannot understand. My corresponding code

final Builder requestConfigBuilder = RequestConfig.custom(); ... final HttpClientBuilder clientBuilder = HttpClientBuilder.create(); clientBuilder.setDefaultCookieStore(); clientBuilder.setDefaultRequestConfig(requestConfigBuilder.build()); ... 

If I use this client, which I receive from my builder, I can see that all the cookies sent in my request are as expected. However, adding a cookie specification, for example:

 final Builder requestConfigBuilder = RequestConfig.custom(); ... requestConfigBuilder.setCookieSpec(CookieSpecs.DEFAULT); //this causes problems final HttpClientBuilder clientBuilder = HttpClientBuilder.create(); clientBuilder.setDefaultCookieStore(someCookieStoreVariable); clientBuilder.setDefaultRequestConfig(requestConfigBuilder.build()); ... 

I see that no cookies are sent in my request. The result is the same no matter which spec I select from CookieSpecs.

I do not understand or use it incorrectly, why does it not work? Is there any problem setting up another cooking? I need this for future references, so it should stay.

+5
source share
1 answer

Check if the domain and cookie path are set correctly.

+2
source

Source: https://habr.com/ru/post/1240669/


All Articles