【发布时间】:2016-02-24 06:28:07
【问题描述】:
我尝试使用这些代码,但只收到类似的错误消息
错误消息:-NSURLSession/NSURLConnection HTTP 加载失败(kCFStreamErrorDomainSSL,-9813
网址:-http://www.xxxxx.com/XXX/rest/files/downloadFile/en/linto/
Header:- Content-Type: application/x-www-form-urlencoded
RAW:- phoneNumber=%2B15163120019&uname=test
响应头:服务器:Apache-Coyote/1.1
内容类型:文本/xml
传输编码:分块
日期:格林威治标准时间 2016 年 2 月 24 日星期三 05:03:05 生的 已解析
XCODE 版本:7.2.1 我的代码:-
NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: nil delegateQueue: [NSOperationQueue mainQueue]];
NSURL * url = [NSURL URLWithString:@"https://www.indusaudio.com/WeeAudio/rest/files/downloadFile/en/linto/"];
NSMutableURLRequest * urlRequest = [NSMutableURLRequest requestWithURL:url];
[urlRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
NSString * params =@"phoneNumber=%2B15163120019&uname=test";
[urlRequest setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]];
[urlRequest setHTTPMethod:@"POST"];
NSURLSessionDataTask * dataTask =[defaultSession dataTaskWithRequest:urlRequest
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSLog(@"Response:%@ %@\n", response, error);
if(error == nil)
{
// NSString * text = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
//NSLog(@"Data = %@",text);
}
}];
[dataTask resume];
}
【问题讨论】:
标签: ios objective-c xcode post