【发布时间】:2014-01-08 07:19:36
【问题描述】:
我有一个 HTTPS 请求。
我正在使用NSURLConnection 的sendAsynchronousRequest。我不想使用
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
当我使用NSURLConnection 的sendAsynchronousRequest 时,每次我都会收到以下错误
NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)
CFNetwork SSLHandshake failed (-9806)
这是我的代码
NSURL *url=[NSURL URLWithString:strService];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
[theRequest setHTTPMethod:@"POST"];
NSString *msgLength = [NSString stringWithFormat:@"%d", [strSoap length]];
[theRequest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];;
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setValue:@"My User-Agent" forHTTPHeaderField:@"User-Agent"];
[theRequest addValue:strSoapAction forHTTPHeaderField:@"SOAPAction"];
[theRequest setHTTPBody: [strSoap dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:TRUE]];
[NSURLConnection sendAsynchronousRequest:theRequest queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *resp, NSData *responseData, NSError *error) {
NSString *strResponse=[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding] ;
strResponse=[self clearHtmlTags:strResponse];
NSMutableDictionary *dictResponse=[NSMutableDictionary dictionaryWithDictionary:[NSDictionary dictionaryWithXMLString:strResponse]];
block(dictResponse);
}];
这是用 sendAsynchronousRequest 调用 NSURLConnection 的委托方法的任何其他方式吗?
【问题讨论】:
标签: ios http-post nsurlconnection