跟雅思的项目对比,发现
task.currentRequest.allHTTPHeaderFields
这样不能拿到cookie
应该这样取:
NSHTTPURLResponse *response = (NSHTTPURLResponse *)task.response; NSDictionary *fileds = response.allHeaderFields;//task.currentRequest.allHTTPHeaderFields;//[operation.response allHeaderFields];
NSURL *cookieUrl = [NSURL URLWithString:baseUrl];
NSArray *cookieArray = [NSHTTPCookie cookiesWithResponseHeaderFields:fileds forURL:cookieUrl];