Our XPCOM-based Firefox extension has a feature to output page source by 
loading it from cache using nsICachingChannel and a cacheKey, similar to 
the way that Firefox itself does it (and also Firebug).

However, the issue we have is that we don't want to generate any new 
network requests while inspecting and outputting the page source, as we 
already track network activity very closely and doing so would pollute 
the network results we are capturing.  In testing, we've tried using the 
LOAD_NO_NETWORK_IO and LOAD_ONLY_FROM_CACHE flags, but have seen no 
change in behavior... ultimately the call to stream=channel.open() still 
forces a network request.  Perhaps the Cache-Control header tags 
(private, no-cache, no-store, etc) on the requested pages are causing 
the load flags we want to not be honored.

But even if that worked, it would only give us the source for cached 
pages.  What we really need is a way to hook into the request-channel's 
data stream while the document source initially comes through, and not 
doing it after-the-fact via cache lookup, at which time we would store 
either a reference or our own copy of the source from the stream, to be 
either output or discarded later.

So my question is, what would be the best way to do this?  Would reading 
the channel's stream inside my onStateChange handler when the state 
flags match STATE_STOP/STATE_IS_DOCUMENT/STATE_IS_REQUEST be the right 
place?  Would non-cacheable pages already be evicted at that point?  Do 
we need to rewind the stream after inspection?  Note, we do have the 
option of modifying the firefox sources (necko) if necessary, but we're 
trying to avoid going with that approach if possible.
_______________________________________________
dev-tech-network mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-network

Reply via email to