title: Modifying all HTTP requests on iPhoneOS with MobileSubstrate?
body: <p>I want to write a MobileSubstrate (<a href="http://www.iphonedevwiki.net/index.php/MobileSubstrate" rel="nofollow noreferrer">http://www.iphonedevwiki.net/index.php/MobileSubstrate</a>) 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.</p>
  
  <p>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:<br />
  1) User in MobileSafari types in aaa.com/a.html<br />
  2) aaa.com/a.html redirects to aaa.com/b.html<br />
  3) aaa.com/b.html loads bbb.com/c.png<br />
  I want to change the request so everything has ?i=j added.<br />
  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?<br />
  <br />
  And another one:<br />
  1) User uses Maps.app<br />
  2) Google Maps tries to load google.com/map1.png (not actual image, I know)<br />
  Change google.com/map1.png to google.com/map1.png?i=j?<br /></p>