通过Apache HTTP Client Fluent界面设置cookie

时间:2014-07-29 13:07:45

标签: java http cookies apache-httpcomponents

我想这样做:

Content result = Request
    .Get("url.com")
    .addHeader("CookieName", "CookieValue") // is this the proper way ?
    .execute()
    .returnContent();

org.apache.http.client.fluent.Request。这是Apache HTTP Components的一部分。

我似乎无法在文档中找到它,对此感到抱歉并感谢您的帮助。

1 个答案:

答案 0 :(得分:6)

CookieStore cookieStore = new BasicCookieStore();
//cookieStore.addCookie();
Executor executor = Executor.newInstance();
executor.cookieStore(cookieStore)
        .execute(Request.Get("/stuff"))
        .returnContent();