gpt4 book ai didi

java - 从 httpclient 3 转换为 httpclient 4(Cookie 策略)

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:06:15 24 4
gpt4 key购买 nike

之前,我在httpclient3中有如下代码

// To prevent cookie warnings.
httpClient.getParams().setParameter("http.protocol.single-cookie-header", true);
httpClient.getParams().setCookiePolicy(org.apache.commons.httpclient.cookie.CookiePolicy.BROWSER_COMPATIBILITY);

我想知道,httpclient4 中的等效代码是什么,因为我在第二行遇到错误。

// To prevent cookie warnings.
httpClient.getParams().setParameter("http.protocol.single-cookie-header", true);
// ??? compilation error in this line.
// org.apache.commons.httpclient cannot be resolved to a variable
httpClient.getParams().setCookiePolicy(org.apache.commons.httpclient.cookie.CookiePolicy.BROWSER_COMPATIBILITY);

最佳答案

此链接可以帮助您解决问题。

http://www.wirelust.com/2009/03/29/howto-set-the-cookie-policy-with-apache-http-client-40/

所以试试这一行:

httpClient.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY);

关于java - 从 httpclient 3 转换为 httpclient 4(Cookie 策略),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11122950/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com