mshtml image download redirection
-
Hello ! I have some experience with com/webbrowser/mshtml. Recently I run into a very interesting problem, and after spending some days on it(no success) I decided to try geting some answers from other programmers. So: I wrote a simple browser helper object. On a machine without internet access, when detecting BeforeNavigate2 event, I redirect navigation. For example, if the user enters http://www.google.com, i redirect to http://mygateway/page.aspx?url="http://www.google.com". This works fine, the problem is I can't redirect the location of the objects in the document (objects; images; flash; etc), and the page can not load them. I couldn't find an event that fires when a resource download begins, and a mechanism for redirecting these downloads. (please note that implementing a download manager dows not solve this problem; dm objects are invoked only when the user explicitly selects "download targer..." from the context menu for example). Please let me know if you have any ideas ( is it possible ? is it not ? a source for more info -> i've already read all I could find in msdn and microsoft on this topic and got no answer ). I don't need specific code / code samples, I only need a hint on how to do it. I'm not interested in parsing the html code and modifying the links. pages may contain flash/applets, and i can't parse them to change the links. I need browser redirection. As soon as I'll solve this problem, I'll post the project (no mfc; no atl; just pure C++/Com). All the best, psangeljg ps. I did find a solution, but it's not what I want. I figured that mshtml uses wininet (wininet.dll) to access the resources. I could write my own wininet.dll that calls the actual wininet.dll, changing the urls. However, I try to avoid this soultion, since wininet.dll varies with the os version. Performance is also important.
-
Hello ! I have some experience with com/webbrowser/mshtml. Recently I run into a very interesting problem, and after spending some days on it(no success) I decided to try geting some answers from other programmers. So: I wrote a simple browser helper object. On a machine without internet access, when detecting BeforeNavigate2 event, I redirect navigation. For example, if the user enters http://www.google.com, i redirect to http://mygateway/page.aspx?url="http://www.google.com". This works fine, the problem is I can't redirect the location of the objects in the document (objects; images; flash; etc), and the page can not load them. I couldn't find an event that fires when a resource download begins, and a mechanism for redirecting these downloads. (please note that implementing a download manager dows not solve this problem; dm objects are invoked only when the user explicitly selects "download targer..." from the context menu for example). Please let me know if you have any ideas ( is it possible ? is it not ? a source for more info -> i've already read all I could find in msdn and microsoft on this topic and got no answer ). I don't need specific code / code samples, I only need a hint on how to do it. I'm not interested in parsing the html code and modifying the links. pages may contain flash/applets, and i can't parse them to change the links. I need browser redirection. As soon as I'll solve this problem, I'll post the project (no mfc; no atl; just pure C++/Com). All the best, psangeljg ps. I did find a solution, but it's not what I want. I figured that mshtml uses wininet (wininet.dll) to access the resources. I could write my own wininet.dll that calls the actual wininet.dll, changing the urls. However, I try to avoid this soultion, since wininet.dll varies with the os version. Performance is also important.
The problem is most likely due to relative urls. You need to rewrite all urls in the orignal document to absolute urls.
-
The problem is most likely due to relative urls. You need to rewrite all urls in the orignal document to absolute urls.
-
Hello ! I have some experience with com/webbrowser/mshtml. Recently I run into a very interesting problem, and after spending some days on it(no success) I decided to try geting some answers from other programmers. So: I wrote a simple browser helper object. On a machine without internet access, when detecting BeforeNavigate2 event, I redirect navigation. For example, if the user enters http://www.google.com, i redirect to http://mygateway/page.aspx?url="http://www.google.com". This works fine, the problem is I can't redirect the location of the objects in the document (objects; images; flash; etc), and the page can not load them. I couldn't find an event that fires when a resource download begins, and a mechanism for redirecting these downloads. (please note that implementing a download manager dows not solve this problem; dm objects are invoked only when the user explicitly selects "download targer..." from the context menu for example). Please let me know if you have any ideas ( is it possible ? is it not ? a source for more info -> i've already read all I could find in msdn and microsoft on this topic and got no answer ). I don't need specific code / code samples, I only need a hint on how to do it. I'm not interested in parsing the html code and modifying the links. pages may contain flash/applets, and i can't parse them to change the links. I need browser redirection. As soon as I'll solve this problem, I'll post the project (no mfc; no atl; just pure C++/Com). All the best, psangeljg ps. I did find a solution, but it's not what I want. I figured that mshtml uses wininet (wininet.dll) to access the resources. I could write my own wininet.dll that calls the actual wininet.dll, changing the urls. However, I try to avoid this soultion, since wininet.dll varies with the os version. Performance is also important.
-
Yep, just like Stefan said. You can obtain a pointer to the HTML document you have loaded after you get the documentComplete event. Trough that pointer you can get and set for example the sources of the images or objects found on the page.
that's similar to parsing; you can't manage activex controls, links embedded in flash objects and the like; this works only for good old fashioned html, and that's not the case here; I need a tool that can handle any web page; the solution I implemented after one week of searching for alternates was using proxy server. That's also what igor1960 proposed, and it seems to me it's the only answer. Writing a proxy server is not a very complicated task, so it is an acceptable solution.
-
Maybe there is way to do that by setting proxy server?. "...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..." Me