0

在我的 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() 返回缺少数据?提前致谢

4

1 回答 1

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.Key 是 RFC2965。

请参阅与HttpCookie相关的文档,它链接到具有必须遵循的特定语法/值的 RFC 文档。

于 2013-11-10T00:30:00.677 回答