Proxies with NSURLRequest

I am using NSURLConnection and NSURLRequest to connect to the server for my OS X application.

Now I would like to implement a specific connection with a proxy server, but I can not find something about this in the docs.

I want the web view to be viewed through a proxy server, which I define, and not change the proxy settings of the machine / device.

Has anyone tried this or knew how to handle proxies from Objective-C?

+4
source share
1 answer

I found the answer myself. I found that ASIHTTPRequest has what I need:

 NSURL *url = [NSURL URLWithString:@"http://minip.no"]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setProxyHost:[chosenprox objectForKey:@"host"]]; [request setProxyPort:[[chosenprox objectForKey:@"port"] intValue]]; [request setDelegate:self]; [request startSynchronous]; if ([request error]) { [mainFrame loadHTMLString:[[request error] localizedDescription] baseURL:nil]; } else if ([request responseString]) { [mainFrame loadHTMLString:[request responseString] baseURL:nil]; } 

And he has other nice uses.

0
source

All Articles