Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Choosing any CookieSpec removes all cookies in request

I have a problem I can't seem to grasp. My relevant code is

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

If I use this client I get from my builder, I can see all cookies being sent in my request as I would expect. However, adding a cookie spec, like this:

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 no cookies being sent in my request. The result is the same no matter which spec I choose from CookieSpecs.

Am I misunderstanding or misusing this, why doesn't this work? Is there some problem with me setting another cookiestore? I do need it for future references so it has to stay.

like image 281
Pengtuzi Avatar asked Oct 30 '22 11:10

Pengtuzi


1 Answers

Check whether cookie domain and path are set properly.

like image 89
BValluri Avatar answered Nov 13 '22 05:11

BValluri