我正在尝试使用 AFNetworking 和 AFJSONRequestOperation 发送授权标头。如果我在 setAuthorizationHeaderWithToken 之后对 httpClient 进行 NSLog,它会显示它在标头中,但是当我检查它发送到的服务器时,它似乎没有收到 Authorization 标头(它接收其他部分)。
AFJSONRequestOperation 是否对未添加授权部分的标头执行某些操作?
NSURL *url = [NSURL URLWithString:kBaseURL];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST" path:@"/" parameters:params];
[httpClient setAuthorizationHeaderWithToken:@"test"];
AFJSONRequestOperation *operation = nil;
operation = [AFJSONRequestOperation
JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
}
failure:^(NSURLRequest *request , NSHTTPURLResponse *response, NSError *error , id JSON ){
}];
[operation start];