title: Intercept all get requests in html5 application on windows phone
body: <p>Corodva, Javascript and HTML5 developers.</p>
  
  <p>I need to intercep all get requests made by the WebBrowser component in Windows Phone 8.0 at any point and be able to view the resource that it's requesting. To give an example of "all", this is what I mean.</p>
  
  <p>I have a simple application that contains a cordova(WebBrowser control with Decorators that allows XHRrequests to be retrieved from local storage) view, and navigates to an index.html file. </p>
  
  <p>The index.html contains only the following in the body</p>
  
  <pre><code>&lt;img src="logo.png" /&gt;
  </code></pre>
  
  <p>This file is loaded and displayed by the web browser but there is not interceptable request made through the web browser to the Windows Phone that I can see. The file just appears in the browser magically. I know that cordova overwrites all XHRrequests to swap out for local files. No method in the XHRHelper.cs is being hit with a request for logo.png. Here is everything I have tried just so we can all be on the same page.</p>
  
  <ul>
  <li>Subscribed to the Navigating, Navigated and NavigationFailed (Just because there's no other option) events to see if it fires at any point to load logo.png. This turned out nothing, it only fired for actual navigation calls made within the application. I also subscribed to all, I literally mean all events available from the WebBrowser control. Even ones that are inherited from UIElement.</li>
  <li>Tried to wrap the WebBrowser in a COM Wrapper that "monitors" all outgoing traffic using <a href="http://www.codeproject.com/Articles/157329/Http-Monitor-for-Webbrowser-Control" rel="nofollow noreferrer">http://www.codeproject.com/Articles/157329/Http-Monitor-for-Webbrowser-Control</a> which does not work for Windows Phone 8.0 Web browser control. Was still a good exercise. It also does not get requests made for local files. </li>
  <li>The next option I checked out is a way of intercepting all requests from JavaScript for anything, but found many posts that only explain how to intercept all AJAX requests, which is not what I want to do.</li>
  <li>I then implemented the ways of intercepting all AJAX requests to see if it will give some insight on what I could possibly do. Nothing panned out from this exercise. I then also did this [<a href="https://stackoverflow.com/questions/21976174/how-do-you-intercept-all-http-requests-in-an-emberjs-app][this]">How do you &#39;intercept&#39; all HTTP requests in an EmberJs app?</a>. Ant that also did not help, I then looked at intercept.js and tried to use that, but again the logo.png slipped the grasp of intercept.js aswell</li>
  <li>Me being a Windows Phone .NET developer and not at all experienced in JavaScript except for 6 months of wrapping HTML5 apps into cordova I returned back to the windows phone code trying to catch the navigation as it leaves the WebBrowser control. I tried to override all the methods that were specific to a WebBrowser and tried to cancel any and all requests, just to see if logo.png would still appear in the browser and it did :(</li>
  </ul>
  
  <p>I wouldn't ask this question if I didn't do any research on this subject. Some of the JavaScript devs said that they don't think it's possible from inside the application, many of the C++ developers said I should look at the native code implementation for the WebBrowser control, find out what interfaces it extends and get hold of it for extension somehow. I will be attempting to do this tomorrow all day, but would like to not overkil the situation if there's (hopefully) an easy way of doing this. </p>
  
  <p>My next step is to use a tool like fiddler or charles to monitor all packets through a proxy. If I can see requests made for the local files through any of these tools then there must be a way to intercept those requests in code. If this is successfull I will attempt to set up a local proxy at runtime and redirect through my filehandler.</p>
  
  <p>I spoke to some iOS developers and they used NSURLProtocol, which you just have to set up then you can monitor all you traffic (Lucky). Is there anything like this for Windows Phone 8.0? Does anyone have suggestions on how I could implement this for Windows Phone 8.0? Is there any way I can intercept all requests from a html5 app. Any way would be fine, I'm fairly confident that I'll be able to implement any suggestion and give feedback if it does not work. The biggest question would be if it's even possible.</p>
  
  <p>Any feedback would be appreciated, and any suggestions will be followed through. And I will provide feedback on that suggestion.</p>
  
  <p>Thank you in advance, I know there are some serious Code Ninjas on here that will give me a  million options :)</p>