NSHTTPCookieStorage UTF-8 cookie名称值被截断

时间:2014-10-01 11:28:52

标签: ios7 cookies nshttpcookie nshttpcookiestorage

在iOS 7应用中,我使用NSHTTPCookieStorage将Cookie存储在sharedHTTPCookieStorage中。

我收到的其中一个cookie的名称值中包含非ASCII字“Søren”。我可以看到cookie在HTTP跟踪中设置,但sharedHTTPCookieStorage中保存的cookie在“Søren”中的“S”之后被截断。 HTTP响应头中设置的后续cookie均未存储在sharedCookieStorage中。事实上,违规cookie以截断形式存储两次,几乎就像框架试图再次解析然后放弃一样。

RFC2965声明:

  

NAME = VALUE         需要。状态信息(“cookie”)的名称是NAME,         它的值是VALUE。以$开头的名称是保留的         不得由应用程序使用。

  The VALUE is opaque to the user agent and may be anything the
  origin server chooses to send, possibly in a server-selected
  printable ASCII encoding.  "Opaque" implies that the content is of
  interest and relevance only to the origin server.  The content
  may, in fact, be readable by anyone that examines the Set-Cookie2
  header.

我正在配置NSHTTPCookieStorage,如下所示:

NSHTTPCookieStorage *sharedCookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
[sharedCookieStorage setCookieAcceptPolicy:(NSHTTPCookieAcceptPolicyAlways)];

我认为这与NSHTTPCookieStorage有关,而不是NSURLResponse。我是否需要执行任何其他操作来处理UTF-8 cookie名称值?

0 个答案:

没有答案