//从Cookies响应头获取header
###代码块
- (void)getCookies {
NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
NSArray*cookieArr = [cookieJarcookies];
for(NSHTTPCookie*cookieincookieArr) {
if([cookie.nameisEqualToString:@"SID"]) {
//存储cookies
[XMCentersetupConfig:^(XMConfig*_Nonnullconfig) {
config.generalHeaders=@{@"SID": cookie.value};
}];
_cookie= cookie.value;
}
//存储之后删除cookies
[cookieJardeleteCookie:cookie];
}
}
2.获取header信息
NSURLResponse*_Nullable response.......NSHTTPURLResponse*r=(NSHTTPURLResponse*)response;NSDictionary*dict=[r allHeaderFields];self.cookie=dict[@"salt"];