Java 为什么要为HttpHead方法获取cookie?
我们使用HttpHead从客户的网站上获取信息,但出于某些原因,我们在响应中也得到了cookie。这是预期的吗?有没有办法设置为不返回cookie 下面是我们的代码Java 为什么要为HttpHead方法获取cookie?,java,cookies,warnings,httpclient,Java,Cookies,Warnings,Httpclient,我们使用HttpHead从客户的网站上获取信息,但出于某些原因,我们在响应中也得到了cookie。这是预期的吗?有没有办法设置为不返回cookie 下面是我们的代码 HttpClient httpclient = new DefaultHttpClient(); // the time it takes to open TCP connection. httpclient.getParams().setParameter(CoreConnectio
HttpClient httpclient = new DefaultHttpClient();
// the time it takes to open TCP connection.
httpclient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, this.timeout);
// timeout when server does not send data.
httpclient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, this.timeout);
// the head method
HttpHead httphead = new HttpHead(url);
HttpResponse response = httpclient.execute(httphead);
我们得到了以下警告,表明cookie也返回了响应
[警告]响应进程Cookies-拒绝Cookie:“[版本:0][名称:DXFXFSG][值:AUR][域:…省略…][路径:/][到期日:null]”。非法的域属性“…省略…”。原产地:“…省略…”是,预期为;除了没有主体之外,您应该得到与等效的
get
相同的响应。如果GET
包含cookie,您应该看到它
另一方面,我相信您从您提供的编辑消息中看到的警告是,服务器正在尝试为其他域设置cookie。谢谢您的确认。我认为你的观察是正确的。听起来似乎没有办法阻止服务器端返回cookies。