小编Ale*_*rov的帖子

NSURLRequest不发送cookie

我正在开发报摊应用程序并使用NSURLRequest下载问题资产.

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];
    ....
}
Run Code Online (Sandbox Code Playgroud)

执行第一个for循环时,我的cookie似乎在NSHTTPCookieStorage中,但是当发送实际请求时,标头中没有cookie信息.我使用CharlesProxy来查看它.有谁可以请一些可能导致这个问题的建议?

cocoa cocoa-touch objective-c ios newsstand-kit

13
推荐指数
1
解决办法
7965
查看次数

标签 统计

cocoa ×1

cocoa-touch ×1

ios ×1

newsstand-kit ×1

objective-c ×1