getter_AddRefs(pChannel));
nsnull, getter_AddRefs(pChannel));
nsresult StartLoadingURL(const char* aUrlString){    nsresult rv;    NS_WITH_SERVICE(nsIIOService, pService, kIOServiceCID, &rv);    if (pService) {        nsCOMPtr<nsIURI> pURL;        rv = pService->NewURI(aUrlString, nsnull, getter_AddRefs(pURL));        if (NS_FAILED(rv)) {            printf("ERROR: NewURI failed for %s\n", aUrlString);            return rv;        }        nsCOMPtr<nsIChannel> pChannel;        nsEventSinkGetter* pMySink;        pMySink = new nsEventSinkGetter();        NS_IF_ADDREF(pMySink);        if (!pMySink) {            NS_ERROR("Failed to create a new consumer!");            return NS_ERROR_OUT_OF_MEMORY;;        }        // Async reading thru the calls of the event sink interface        rv = pService->NewChannelFromURI("load", pURL, nsnull, pMySink,                                          getter_AddRefs(pChannel));        if (NS_FAILED(rv)) {            printf("ERROR: NewChannelFromURI failed for %s\n", aUrlString);            return rv;        }        NS_RELEASE(pMySink);        /*            You may optionally add/set other headers on this           request object. This is done by QI for the specific           protocolConnection.        */        nsCOMPtr<nsIHTTPChannel> pHTTPCon(do_QueryInterface(pChannel));        if (pHTTPCon) {            // Setting a sample header.            nsCOMPtr<nsIAtom> sampleHeader;            sampleHeader = NS_NewAtom("sample-header-minus-the-colon");            rv = pHTTPCon->SetRequestHeader(sampleHeader, "Sample-Value");            if (NS_FAILED(rv)) return rv;        }                    InputTestConsumer* listener;        listener = new InputTestConsumer;        NS_IF_ADDREF(listener);        if (!listener) {            NS_ERROR("Failed to create a new stream listener!");            return NS_ERROR_OUT_OF_MEMORY;;        }        if (gTestAsyncOpen) {            OpenObserver* obs = new OpenObserver(listener);            if (obs == nsnull)                 return NS_ERROR_OUT_OF_MEMORY;            NS_ADDREF(obs);            rv = pChannel->AsyncOpen(obs, nsnull);            NS_RELEASE(obs);            if (NS_FAILED(rv)) {                NS_ERROR("Error: AsyncOpen failed...");                return rv;            }        }        URLLoadInfo* info;        info = new URLLoadInfo(aUrlString);        NS_IF_ADDREF(info);        if (!info) {            NS_ERROR("Failed to create a load info!");            return NS_ERROR_OUT_OF_MEMORY;        }                rv = pChannel->AsyncRead(0,         // staring position                                 -1,        // number of bytes to read                                 info,      // ISupports context                                 listener); // IStreamListener consumer        if (NS_SUCCEEDED(rv)) {            gKeepRunning += 1;        }        NS_RELEASE(listener);        NS_RELEASE(info);    }    return rv;}