Cookies java.net.ProtocolException:错误的设置Cookie头
下面给出了供您参考的代码块:Cookies java.net.ProtocolException:错误的设置Cookie头,cookies,header,http-headers,httpcookie,httponly,Cookies,Header,Http Headers,Httpcookie,Httponly,下面给出了供您参考的代码块: String hostname = "Hostname Value"; URI uri = new URI(hostname + "/solr/add/story/" + story.getId() + ".html"); final HTTPConnection con = new HTTPConnection(uri); con.setAllowUserInteraction(false); final HTTPResponse response = con.G
String hostname = "Hostname Value";
URI uri = new URI(hostname + "/solr/add/story/" + story.getId() + ".html");
final HTTPConnection con = new HTTPConnection(uri);
con.setAllowUserInteraction(false);
final HTTPResponse response = con.Get(uri.getPathAndQuery());
在这里,当访问响应时,我得到以下异常:
[ WARN] [com.thestreet.cms.integration.solr.SolrService] 12/02/2013 22:52:54-Unable
update front end search engine index with story 10446446
java.net.ProtocolException: Bad Set-Cookie header: FV=OID-|PID-|MID-|PUC-|DATE-
529D5595; path=/; expires=Tue, 01-Jan-2035 00:00:00 GMT; domain=.thestreet.com;,
BRIS=C0.A8.41.91|529D55951FB74EF; path=/; expires=Tue, 01-Jan-2035 00:00:00 GMT;
domain=.thestreet.com;,
RGIS=-1386042773,192.168.65.145,BA42A8C0,1076F795713A21E010941898- 0-1386042773-;
path=/; expires=Tue, 01-Jan-2035 00:00:00 GMT; domain=.thestreet.com;,
JSESSIONID=8A8A377CF937F6184D3F4774CC6F4CBA; Version=1; Path="/"; HttpOnly
No '=' found for token starting at position 432
at HTTPClient.Cookie.parse(Cookie.java:243)
at HTTPClient.CookieModule.handleCookie(CookieModule.java:454)
at HTTPClient.CookieModule.responsePhase1Handler(CookieModule.java:403)
at HTTPClient.HTTPResponse.handleResponse(HTTPResponse.java:724)
at HTTPClient.HTTPResponse.getStatusCode(HTTPResponse.java:190)
at com.thestreet.cms.integration.solr.SolrService$1.run(SolrService.java:450)
at java.lang.Thread.run(Thread.java:722)
这似乎是由cookie头中的Httponly位引起的,因为它不是键值对的形式。在读取响应时,有没有办法避免cookie头或cookie检查?请帮忙
提前感谢。问题在于您的http请求/响应的标题中包含“HttpOnly”。应用服务器似乎不再支持此值。为了解决这个问题,我编写了一个变通方法,从服务器端的响应中删除“HttpOnly”
String header = resp.getHeader("Set-Cookie");
if (header != null && header.endsWith("HttpOnly")) {
resp.setHeader("Set-Cookie", header.substring(0, header.length() - 8));
}
但最好的解决方案是从http客户端的头中删除“HttpOnly”。有人能帮我解决这个问题吗???