gpt4 book ai didi

java - HttpClient 警告 : Cookie rejected: Illegal domain attribute

转载 作者:IT老高 更新时间:2023-10-28 20:37:41 30 4
gpt4 key购买 nike

我正在使用 HttpClient 最新版本 (4.x)。现在我正在尝试做一个 GET 请求。我只是发布了一个获取请求。

这是我的代码;

public class Poster {

static boolean routing1 = true, routing2 = true;
static int counter1 = 0, counter2 = 0;
DefaultHttpClient oHtp = null;
HttpGet oHGet = null;
HttpResponse oHRes = null;


private void test(String fullAddress) throws Exception {
oHtp = new DefaultHttpClient();
oHGet = new HttpGet(fullAddress);

HttpResponse response = oHtp.execute(oHGet);
System.out.print(response.getStatusLine());

HttpEntity entity = response.getEntity();
if (entity != null) {
entity = new BufferedHttpEntity(entity);
// System.out.println(EntityUtils.toString(entity));
System.out.print("\t entity is retrieved... ");
}


oHtp.getConnectionManager().shutdown();
}
}

我只是很好地执行它。首先是

new Poster().test("http://123.xl.co.id/profile.php");

第二个是

 new Poster().test("http://goklik.co.id/");

是的,只有第二个....我收到了这个错误消息;

Sep 18, 2011 10:11:30 AM org.apache.http.client.protocol.ResponseProcessCookies processCookies WARNING: Cookie rejected: "[version: 0][name: CookiePst][value: 0149=xwGHF7HYDHLHQ84Isp/eSy9vu+Xq6cT12wxg1A==][domain: .mcore.com][path: /][expiry: Sun Sep 18 10:38:59 ICT 2011]". Illegal domain attribute "mcore.com". Domain of origin: "goklik.co.id"

我意识到这里涉及到 Cookie。但我不明白警告的含义。而且我也不知道如何解决(Cookie没有被拒绝)。希望有一点光明可以让你们清除我的思绪....:D

最佳答案

也许为时已晚,但我遇到了同样的问题,我找到了一些帮助我解决问题的方法,只需设置 Cookie Policy浏览器兼容性:

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

以下是可能的值:

The cookie policy provides corresponding cookie management interfrace for a given type or version of cookie.

RFC 2109 specification is used per default. Other supported specification can be chosen when appropriate or set default when desired

The following specifications are provided:

  • BROWSER_COMPATIBILITY: compatible with the common cookie management practices (even if they are not 100% standards compliant)
  • NETSCAPE: Netscape cookie draft compliant
  • RFC_2109: RFC2109 compliant (default)
  • IGNORE_COOKIES: do not automcatically process cookies

关于java - HttpClient 警告 : Cookie rejected: Illegal domain attribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7459279/

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