Ios NSURLConnection是否无法发出HTTPS GET请求?
我只是在做我对HTTP请求所做的事情:Ios NSURLConnection是否无法发出HTTPS GET请求?,ios,ssl,https,request,nsurlconnection,Ios,Ssl,Https,Request,Nsurlconnection,我只是在做我对HTTP请求所做的事情: NSString *urlStrig = [NSString stringWithFormat:@"https://mysite.com/search.json?param1=10¶m2=String¶m3=20"]; NSURL *url = [NSURL URLWithString:urlStrig]; NSOperationQueue *queue = [NSOperationQueue new]; NSURLRequ
NSString *urlStrig = [NSString stringWithFormat:@"https://mysite.com/search.json?param1=10¶m2=String¶m3=20"];
NSURL *url = [NSURL URLWithString:urlStrig];
NSOperationQueue *queue = [NSOperationQueue new];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url cachePolicy:NSURLCacheStorageNotAllowed timeoutInterval:Timeout];
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
NSLog(@"URL:%@\nResponse: %@\nStatusCode: %i\nError: %@", url, [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding], ((NSHTTPURLResponse *)response).statusCode, error);
}];
但每次我都得到403状态码。在终端中通过curl进行测试效果良好
HTTPS和NSURLConnection之间是否存在任何问题?证书问题?你有没有遇到认证挑战?我试过了。我实现了
NSURLConnection
delegate。调用-(void)connection:(NSURLConnection*)connection将发送请求进行身份验证质询:(nsurauthenticationchallenge*)质询
时,我不知道该怎么办。这可能会有帮助:感谢您的帮助。结果发现我在URL中有错误的键名。我就是这样一个noob:(现在我甚至不需要NSURLConnection委托方法。