use*_*464 5 authorization header afnetworking
我正在尝试使用AFNetworking和AFJSONRequestOperation发送Authorization标头.如果我在setAuthorizationHeaderWithToken之后NSLog的httpClient,它将显示它在标题中,但是当我检查它发送到的服务器时,它似乎没有收到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];
Run Code Online (Sandbox Code Playgroud)
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];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1996 次 |
| 最近记录: |