我正在開發一個報刊亭的應用和使用的NSURLRequest下載的問題資產。的NSURLRequest不發送cookie
NSArray *contents = [issue.tableOfContents objectForKey:kSNTableOfContentsContents];
NSHTTPCookie *cookie;
NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
NSLog(@"HERE GO MY COOKIES");
for (cookie in [cookieJar cookies]) {
NSLog(@"%@", cookie);
}
for (NSDictionary *contentItem in contents) {
NSString *contentURL_string = [contentItem objectForKey:kSNTableOfContentsRemoteURL];
NSURL *contentURL = [NSURL URLWithString:contentURL_string];
NSString *fileName = [contentItem objectForKey:kSNTableOfContentsContentsURL];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:contentURL];
NKAssetDownload *asset = [newsstandIssue addAssetWithRequest:request];
[request release];
....
[asset downloadWithDelegate:self];
....
}
當第一個for循環執行了我的餅乾似乎是在NSHTTPCookieStorage,但是當實際的請求被髮送,也有頭無cookie信息。我用CharlesProxy來看看。任何人都可以請提供一些建議可能會導致這個問題?
你可以嘗試手動做:http://stackoverflow.com/questions/5954382/ios-is-it-possible-to -set-a-cookie-manually-using-sharedhttpcookiestorage-for-a – 2012-03-30 17:59:58
謝謝,我會試試看。 – 2012-03-30 18:34:52