I'm setting up a webview but I need to load the content of the webview using a proxy. Any of you knows how can I'm implement the proxy in NSURLRequest?
for example:
NSString *location=@"http://google.com";
NSURL *url=[NSURL URLWithString:location];
NSURLRequest *request=[NSURLRequest requestWithURL:url];
// some code to set the proxy
[self.myWebView loadRequest:request];
I'll really appreciate your help
I have used the below code for Http proxy.
You cannot add a proxy to NSURLRequest. You will need to use a 3rd party library like ASIHTTPRequest.
Take a look at iOS URL Loading System as well as NSURLProtocol
You can write a custom NSURLProtocol class for your NSURLRequest. A custom NSURLProtocol can intercept your requests and add proxy to each request. the relevant method is
-(void)startLoading
, inside this method you can use Core-Function which is a little low-level api in iOS to add the proxy to each request:hope this can help you.
Do forget to register your custom NSURLProtocol to your delegate.