收到的cookie不完全正确

时间:2013-11-10 00:05:20

标签: android cookies httprequest

在我的Android应用程序中,在发布请求后我得到像这样的cookie

HttpResponse httpResponse = httpClient.execute(httpPost);
String cookie = httpResponse.getFirstHeader("Set-Cookie").getValue();

当我在LogCat中打印cookie的值时,其值为PHPSESSID=150edfn1mmr4grmip6pd4h5pv6; path=/

但是,当我通过工具或在线网站发送邮件请求时,例如hurl.it,返回的cookie为PHPSESSID=150edfn1mmr4grmip6pd4h5pv6; path=/, abtesting=0

为什么httpResponse.getFirstHeader(“Set-Cookie”)。getValue()返回缺少数据?提前致谢

1 个答案:

答案 0 :(得分:0)

与许多其他基于Java HttpClient的实现一样。这可能是由于标头的处理,因为基于Set-Cookie规范abtesting=0是无效的属性。

虽然WikiPedia声明The value of a cookie may consist of any printable ascii character (! through ~, unicode \u0021 through \u007E) excluding , and ; and excluding whitespace. The name of the cookie also excludes = as that is the delimiter between the name and value. The cookie standard RFC2965 is more limiting but not implemented by browsers.但关键是RFC2965。

请参阅与HttpCookie相关联的文档,该文档链接到RFC文档,这些文档必须遵循特定的语法/值。