iphone nsurlconnection读取cookie [英] iphone nsurlconnection read cookies
问题描述
我使用异步NSURLConnection从iPhone连接到网站。 Handle didReceiveResponse在响应时被激活,我试图通过使用NSHTTPURLResponse中的allHeaderFields获取所有的cookie
I am using async NSURLConnection to connect to a web site from iPhone. Handle didReceiveResponse is activated on response and I am trying to get all cookies, by using allHeaderFields from NSHTTPURLResponse
我看到很多hreader,但没有Set-Cookie - 看起来像iphone模拟器只是忽略它们...
我确信cookie是存在的响应 - 网络监视器显示他们存在
I see many hreader, but no Set-Cookie - it looks like iphone simulator just ignores them... And I am sure cookies are present in response - network monitor shows they present
我不使用任何http存储 - 所有我试图做的是打印到日志所有标题 - 并且没有看到cookie信息
I do not use any http storage - all that I am trying to do is to print to log all header - and do not see cookies info
有人知道这个问题吗?
UPDATE
我做了一些研究:如果我的网站返回自定义头,如自定义头:值 - 然后这个头在java客户端可见,但不是在iphone ...
UPDATE I have made some research: if my website returns custom header, like "Custom-Header: value" - then this header is visible in java client, but is not in iphone...
感谢
推荐答案
在[[NSHTTPCookieStorage sharedHTTPCookieStorage] cookie中的NSHTTPCookie * cookie]中查找共享的HTTP Cookie存储中的<$ p
$ b
Try to look for it in the shared HTTP cookies storage:
for (NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies])
{
NSLog(@"name: '%@'\n", [cookie name]);
NSLog(@"value: '%@'\n", [cookie value]);
NSLog(@"domain: '%@'\n", [cookie domain]);
NSLog(@"path: '%@'\n", [cookie path]);
}
这篇关于iphone nsurlconnection读取cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!