Mike Lee wrote:
>
> Hi
>
> I'm trying to make use of nsIHttpNotify in javascript through xpconnect.
> I followed some code (nsCookieHTTPNotify.cpp) and it seems to use it you
> first get nsINetModuleMgr then call registerModule(). So here is what I
> got.
>
> var netModuleMgr =
> Components.classes["@mozilla.org/network/net-extern-mod;1"]
> .getService(Components.interfaces.nsINetModuleMgr);
>
> netModuleMgr.registerModule("@mozilla.org/network/moduleMgr/http/response;1",
>
> httpNotify);
>
> Where httpNotify is the nsIHttpNotify implementation. The trouble is
> loading any url httpNotify.onExamineResponse() does not get called.
>
> I'm assuming the problem is nsINetModuleMgr::registerModule() takes
> nsINetNotify as a parameter and not nsIHttpNotify, hence it doen't call
> the nsIHttpNotify::onExamineResponse() listener. In the cookie
> implementation we seem to cast the listener with nsIHttpNotify.
>
> So my question is did I get it all wrong? If not what can I do to get
> this thing working? I would also settle for another solution to get http
> response header for a request if available.
>
> Many thanks
>
are you sure your call to registerModule is executed? the other part of
the puzzle is usually getting your component started up at the right
time. cookies for example adds itself to the http-startup category.
this allows it to be notified when the HTTP module initializes, allowing
it to register itself as a nsIHttpNotify implementation.
darin