In an iOS 7 app I'm using NSHTTPCookieStorage
to store cookies in the sharedHTTPCookieStorage
.
One of the cookies I'm receiving has a name value with the non-ASCII word "Søren" in it. I can see the cookie being set in an HTTP trace, but the cookie held in sharedHTTPCookieStorage
is truncated after the "S" in "Søren". None of the subsequent cookies being set in the HTTP response header are stored in sharedCookieStorage
. In fact the offending cookie is stored in truncated form twice, almost as if the framework tries to parse it again and then gives up.
RFC2965 states:
NAME=VALUE REQUIRED. The name of the state information ("cookie") is NAME, and its value is VALUE. NAMEs that begin with $ are reserved and MUST NOT be used by applications.
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.
I'm configuring NSHTTPCookieStorage
as follows:
NSHTTPCookieStorage *sharedCookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
[sharedCookieStorage setCookieAcceptPolicy:(NSHTTPCookieAcceptPolicyAlways)];
I presume this is related to NSHTTPCookieStorage
, rather than NSURLResponse
. Do I need to do anything additional to handle a UTF-8 cookie name value?