2

在我NSHTTPCookieStorage用来将 cookie 存储在sharedHTTPCookieStorage.

我收到的其中一个 cookie 有一个名称值,其中包含非 ASCII 单词“Søren”。我可以看到在 HTTP 跟踪中设置了 cookie,但保存的 cookiesharedHTTPCookieStorage在“Søren”中的“S”之后被截断。在 HTTP 响应标头中设置的后续 cookie 都不会存储在sharedCookieStorage. 事实上,有问题的 cookie 以截断的形式存储了两次,几乎就像框架试图再次解析它然后放弃一样。

RFC2965 指出:

名称=必填值。状态信息(“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 名称值吗?

4

0 回答 0