I want to add a custom header field to every request made by my UIWebView. First I tried to do this in the "shouldStartLoadWithRequest" method in my controller, but this only works for the first request made - all subsequent requests are not handled by this method.
After some search, I found this tutorial (http://eng.42go.com/customizing-uiwebview-requests-with-nsurlprotocol/). So I implemented my own NSURLProtocol subclass, and everthing is working fine, except my login page - there is some problem with authentication, and I could not solve this. I saw that there exists some methods like "canAuthenticateAgainsProtectionSpace" and "didReceiveAuthenticationChallenge", and I probably need to implement these in order to my login page to work. However, this seems a lot of additional work, since in the first place I just wanted to add a field to every request.
So my doubts are:
- Is there any other easy way to do this?
- If not, should I implement all these authentication methods?
- Is there a way to my custom NSURLProtocol subclass to extends from something like NSURLHTTPProtocol (therefore I would only have minimal work) instead of the NSURLProtocol itself?
Thanks!