Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disable/ignore cookies with httpclient

How can I disable/ignore default cookie handling of httpclient. I want to do it manually. I want to set a pre-defined cookie header for all http requests.

like image 622
Ravs Avatar asked Jan 12 '23 22:01

Ravs


2 Answers

The latest httpclient (4.5.1) has a method called "disableCookieManagement", and it appears this just disables the internal cookie management, not the ability to send or receive cookies, and is working for me-

http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/HttpClientBuilder.html#disableCookieManagement()

like image 87
chrismarx Avatar answered Jan 19 '23 03:01

chrismarx


Set httpclient.setCookieStore(cookieStore); before you execute your HttpClient

like image 23
Apoorv Avatar answered Jan 19 '23 03:01

Apoorv