Let's say I have an iPhone app that has a UIWebView. Is it possible to write my own HTTP proxy server on the iPhone and then have every page that's loaded in the UIWebView go through this proxy?
I guess there are two main parts:
- Write an HTTP proxy server on the iPhone
- Make sure all requests from the UIWebView go through my own proxy
How difficult would it be to write such a proxy server? What would need to be done? I know this is probably very naive of me to think but it sounds rather simple, isn't all you're basically doing just getting messages from the client and routing them to the server? What makes a proxy server so complicated?
This could be useful if you want to modify the HTTP headers of requests that are sent to the UIWebView. Because, while the (NSURLRequest *)request
parameter in [webView:shouldStartLoadWithRequest:navigationType:]
is actually an (NSMutableURLRequest *)
, if you modify any of it's values, it doesn't work (too bad it wasn't that simple).