How can I implement a content converter in Firefox for all page elements?

I am trying to connect the Internet Explorer plugin to Firefox, but I'm not sure where to look for what I need.

Basically, I need to be able to filter all the content received by the browser with a specific Content-Type header. I tried to implement a stream converter, and this works, but only for a top-level document on a page, frame or iframe. I had the same problem with IE, and getting around it was very difficult, and since I would ideally want it to be a cross platform, I would really like to be able to do this in Firefox without resorting to vtable hacks.

Content is transmitted compressed using its own compression format. So I need to get the data, unzip it and change the Content-Type back to what the original uncompressed file should have.

If there is a way to simply filter out all the received data, this would probably be acceptable, I could handle the header itself.

thanks

+6
firefox xpcom
source share
1 answer

I think I might have found what I needed. I came across this link, which is used to track HTTP calls: http://blues.ath.cx/firekeeper/resources/http_tracer.html

For some reason, there are apparently some problems with the JavaScript implementation, and I am not a JavaScript guru to understand this, but I implemented it in C ++, and the original results show that I should be able to modify it for my needs.

Basically, we replace the nsIHttpProtocolHandler service with our own implementation, which keeps a reference to the original implementation. When a call is made for a service, we simply pass it on to the stored original implementation. Then we provide our own implementation of nsIHttpChannel and nsIStreamListener, which we also use as a proxy.

Again we proxied most calls to the original handlers. But in OnDataAvailable, instead of passing data to the base nsIStreamListener, we save it with nsIStorageStream. Then in OnStopRequest, after we got all the data, we can unzip it and then call OnDataAvailable in the source handler and then OnStopRequest.

So far, he has been working on some small simple tests, but I will have to go through more rigorous tests ... I also need to find out if I can do the same with HTTPS.

The biggest problem that I see at the moment is that it relies on some non-freezing interfaces, such as nsIHttpChannelInternal. It is impossible to help, as far as I can tell, and my requirements for version compatibility are pretty small, so I can live with it if I need to.

In the meantime, if anyone has any other suggestions, I'm all ears: D

+3
source share

All Articles