Set a cookie through Apache HTTP Client Fluent interface
-
21-12-2019 - |
Question
I want to do this:
Content result = Request
.Get("url.com")
.addHeader("CookieName", "CookieValue") // is this the proper way ?
.execute()
.returnContent();
with org.apache.http.client.fluent.Request
. Which is a part of Apache HTTP Components.
I can't seem to find it in the docs, sorry about that and thanks for any help.
Solution
CookieStore cookieStore = new BasicCookieStore();
//cookieStore.addCookie();
Executor executor = Executor.newInstance();
executor.cookieStore(cookieStore)
.execute(Request.Get("/stuff"))
.returnContent();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow