问题
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