|
[Request setHTTPMethod: @ "GET"];
// Add the user session id
[Request addValue: @ "text/html" forHTTPHeaderField: @ "Content-Type"];
// Connection sends the request
Finished = false;
NSURLConnection * conn = [[NSURLConnection alloc] initWithRequest: request delegate: self];
// Clog the thread and wait for the end
While (! Finished ){
[[Nsunloop currentRunLoop] runMode: NSDefaultRunLoopMode beforeDate: [NSDate distantFuture];
}
}
-(Void) connection :( NSURLConnection *) connection didReceiveResponse :( NSURLResponse *) response
{}
-(Void) connectionDidFinishLoading :( NSURLConnection *) connection
{
// [_ WaitingDialog dismissWithClickedButtonIndex: 0 animated: NO];
[Connection release];
}
-(Void) connection :( NSURLConnection *) connection didFailWithError :( NSError *) error
{
}
-(BOOL) connectionShouldUseCredentialStorage :( NSURLConnection *) connection {
Return NO;
}
// The following two sections are important. Server-side individual HTTPS verification is required, and the iOS client ignores certificate verification.
-(BOOL) connection :( NSURLConnection *) connection canAuthenticateAgainstProtectionSpace :( NSURLProtectionSpace *) protectionSpace {
Return [protectionSpace. authenticationMethod isinclutostring: NSURLAuthenticationMethodServerTrust];
}
-(Void) connection :( NSURLConnection *) connection didReceiveAuthenticationChallenge :( NSURLAuthenticationChallenge *) challenge {
NSLog (@ "didReceiveAuthenticationChallenge % @ % zd", [[challenge protectionSpace] authenticationMethod], (ssize_t) [challenge previusfailurecount]);
If ([challenge. protectionSpace. authenticationMethod isinclutostring: NSURLAuthenticationMethodServerTrust]) {
[[Challenge sender] useCredential: [NSURLCredential credentialForTrust: challenge. protectionSpace. serverTrust] forAuthenticationChallenge: challenge];
[[Challenge sender] continueWithoutCredentialForAuthenticationChallenge: challenge];
}
}
NSLog (@ "get the whole response ");
// [ReceivedData setLength: 0];
}
// Process data
-(Void) connection :( NSURLConnection *) connection didReceiveData :( NSData *) data
{
} |