我只是在做我对 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];
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 之间有什么问题吗?