ios - iOS 9 中的 POST 值获取错误(NSURLSession/NSURLConnection HTTP 加载失败(kCFStreamErrorDomainSSL,-9813)

标签 ios objective-c xcode post

我尝试使用这些代码,但我只收到这样的错误消息

错误消息:-NSURLSession/NSURLConnection HTTP 加载失败(kCFStreamErrorDomainSSL,-9813

网址:- http://www.xxxxx.com/XXX/rest/files/downloadFile/en/linto/

header :-内容类型:application/x-www-form-urlencoded

RAW:-phoneNumber=%2B15163120019&uname=test

响应头:服务器:Apache-Coyote/1.1

内容类型:文本/xml

传输编码:分块

日期:2016 年 2 月 24 日星期三 05:03:05 GMT 生的 已解析

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];

最佳答案

尽量不写斜线

NSURL * url = [NSURL URLWithString:@"https://www.indusaudio.com/WeeAudio/rest/files/downloadFile/en/linto/"];

NSURL * url = [NSURL URLWithString:@"http://www.indusaudio.com/WeeAudio/rest/files/downloadFile/en/linto/"];

关于ios - iOS 9 中的 POST 值获取错误(NSURLSession/NSURLConnection HTTP 加载失败(kCFStreamErrorDomainSSL,-9813),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35594829/

相关文章:

ios - 自动释放的 NSArray 会导致内存泄漏吗?

iOS:当用户强制关闭应用程序时如何像 Parse 那样接收推送通知?

ios - 在 uicollectionview 的 uicollectionviewcell 中包装标签文本

objective-c - 如何通过编写 Objective-C 代码来动态更改 Interface Builder xib 文件?

ios - 授予相机访问权限时出现 BSMachError

ios - 访问了 Xcode 按钮文本,但未反射(reflect)背景更改 UI

ios - ios编程中的网络处理

iphone - 我是否必须在 applicationWillTerminate 中停止 Google Analytics 跟踪器? (iOS)

ios - 如何运行 .xcworkspace 文件

iOS OneSignalNotificationServiceExtension.appex : unknown error -1=ffffffffffffffff