I want to write a MobileSubstrate (http://www.iphonedevwiki.net/index.php/MobileSubstrate) addon that takes every HTTP request and modifies the URL. (The reason is very complicated and would take a while to explain, so just trust me that there's not an alternative). Basically, I need to know what's the best Objective-C message or C function that I should overwrite to intercept any HTTP request, modify the URL, and send the request back to the original function (this shouldn't be just the first request sent by an application, but any redirects too). I think it may be in NSURL or CFNetwork, but am not sure where exactly. This function should, when replaced, work with any apps and the OS itself.
EDIT:
Ok, here's two sample scenarios of what I want to do, note that the method to override should be one that is called by any HTTP request anywhere from an app to the OS:
1) User in MobileSafari types in aaa.com/a.html
2) aaa.com/a.html redirects to aaa.com/b.html
3) aaa.com/b.html loads bbb.com/c.png
I want to change the request so everything has ?i=j added.
EX: Change all aaa.com/a.html to aaa.com/a.html?i=j, aaa.com/b.html?i=j, bbb.com/c.png?i=j?
And another one:
1) User uses Maps.app
2) Google Maps tries to load google.com/map1.png (not actual image, I know)
Change google.com/map1.png to google.com/map1.png?i=j?