HBE08 / httpfox

Automatically exported from code.google.com/p/httpfox
GNU General Public License v2.0
0 stars 0 forks source link

nsIChannel.notificationCallbacks gets overridden, so listeners never get called #47

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
To the httpfox developers:

I am an extension developer and noticed that when httpfox is installed and
running (listening to and intercepting traffic), it prevents a channel's
notification callbacks from being called when the channel is uploading
(POSTing) data.

Specifically, my extension creates an http channel (nsIHttpChannel), and
then sets its notificationCallbacks property as follows:

        var eventSink = {
            onProgress: FUNCTION,
            onStatus: FUNCTION,
            QueryInterface: function(iid) {
                jsdump("eventSink QI");
                if (iid.equals(ci.nsIProgressEventSink) ||
                 iid.equals(ci.nsISupports))
                    return this;
                jsdump("eventSink QI NS_ERROR_NO_INTERFACE");
                Components.returnCode = Components.results.NS_ERROR_NO_INTERFACE;
                return null;
            }
        };

        var progressCallback = {
            getInterface: function(iid) {
                jsdump("progressCallback getInterface, iid requested: " + iid.number);
                if (iid.equals(ci.nsIProgressEventSink)) return eventSink;

                debugger;
                jsdump("progressCallback getInterface NS_ERROR_NO_INTERFACE");
                Components.returnCode = Components.results.NS_ERROR_NO_INTERFACE;
                return null;
            },
            QueryInterface: function(iid) {
                if (iid.equals(ci.nsIInterfaceRequestor) ||
                 iid.equals(ci.nsISupports))
                 return this;

                Components.returnCode = Components.results.NS_ERROR_NO_INTERFACE;
                return null;
            },
        }; 

        httpChannel.notificationCallbacks = progressCallback;
MORE CODE
httpChannel.asyncOpen(CODE);

It is expected that the channel eventually calls progessCallback's
getInterface method, which will return eventSink. When httpfox is running
and intercepting traffice, however, this getInterface call never occurs.
This appears to be a general problem and I don't know how it affects other
Firefox extensions or Firefox itself.

What steps will reproduce the problem?
See above.

What is the expected output? What do you see instead?
See above.

What version of the product are you using? On what operating system?
HttpFox 0.8.2 on Mozilla Firefox 3.0.3, Windows XP SP3 (32-bit).

Please provide any additional information below.
If you need to set your own notificationCallbacks to get information on the
http upload, I suggest that your code:
1. checks for an existing notificationCallbacks property
2. If set, store that property internally.
3. As notificationCallback elements are called (probably requiring
getInterface to the corresponding event sink), process those requests for
HttpFox, and then pass the parameters along to the registered
notificationCallbacks.

Thanks, Sean Leonard

Original issue reported on code.google.com by sean...@gmail.com on 11 Oct 2008 at 7:26

GoogleCodeExporter commented 9 years ago

Original comment by pappkame...@gmail.com on 23 Dec 2008 at 9:14

GoogleCodeExporter commented 9 years ago
thanks for reporting this in such detail

Original comment by pappkame...@gmail.com on 3 Apr 2009 at 10:43

GoogleCodeExporter commented 9 years ago
Seems like this is still an issue in other circumstances (GET instead of 
POST?). See Issue 122 -
http://code.google.com/p/httpfox/issues/detail?id=122

Thanks

Original comment by nilsber...@gmail.com on 7 Sep 2012 at 1:57