How to use HTTPS with NSURLConnection?

馋奶兔 提交于 2019-12-21 06:40:11

问题


I'm interested in HTTPS with NSURLConnection. Is it possible to send a request, respond to a challenge and load the secure URL?

Is there anything else that can be done with NSURLConnection via HTTPS?


回答1:


NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://monsite/mapage.php"]
cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
timeoutInterval:60.0];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[[NSString stringWithFormat:@"score=222"] dataUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];

and then implement the appropiate delegate methods for NSURLConnection.




回答2:


NSUrlConnection works out of the box with HTTPS. You do not have to do anything special.



来源:https://stackoverflow.com/questions/935722/how-to-use-https-with-nsurlconnection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!