Hi,

I am trying to build an XPCOM that monitors the http request and
response headers and data.
I have a working version of a sample, that implements nsIObserver. I
would like to be notified on http-on-modify-request topic, to get hold
of the nsIhttpChannel interface.

My question is, is is okay to do the above in the Observe method
implementation of my XPCOM. FOr eg in "xpcom-startup" or "app-startup"
event. Well, i tried adding them, using AddObserver method, but it
keeps failing.

Dont know where i am goign wrong.

Any help is greatly appreciated.

here is the code snippet

MyComponent::Observe(nsISupports *aSubject, const char *aTopic, const
PRUnichar *aData)
{
        nsresult rv;
        nsCOMPtr<nsIServiceManager> servMan;
        if (strcmp(aTopic,"app-startup")==0)
        {
        rv = NS_GetServiceManager(getter_AddRefs(servMan));
        if (NS_FAILED(rv))
                return rv;
                nsCOMPtr<nsIObserverService> observerService;
                
servMan->GetServiceByContractID("@mozilla.org/observer-service;1",
                        NS_GET_IID(nsIObserverService),
                        getter_AddRefs(observerService));
                if (!observerService)
                        return NS_ERROR_FAILURE;
                rv = observerService->AddObserver(
                        this,
                        "http-on-modify-request", PR_TRUE);
        }
return NS_OK;
}
Thanks,
lav

_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to