I have seen all sorts of questions about modifying NSURLRequest but not NSHTTPURLResponse. Our scenario is that:
- A web page that is loaded in a UIWebview will make an HTTP request. This is typically a form post in a hidden iFrame or AJAX request. All that we can control is the host name of the request. We cannot modify anything else in the webpage.
- In the UIWebviewDelegate the request is captured. We extract some data out of the request URL. That data is processed and a result is generated.
- Then I need to provide a custom NSHTTPURLResponse that includes the result from #2 to the web view.
This is similar to the basic functionality of a Java Servlet. I have not found any way of being able to achieve #3.
Also UIWebviewDelegate doesn't seem to capture AJAX requests. There doesn't seem to be any workaround without placing custom java script in the web page as outlined here: UIWebViewDelegate not monitoring XMLHttpRequest?