if (loadGroup) { rv = channel->SetLoadGroup(loadGroup); if (NS_FAILED(rv)) return rv; } if (notificationCallbacks) { rv = channel->SetNotificationCallbacks(notificationCallbacks); if (NS_FAILED(rv)) return rv; } if (loadAttributes != nsIChannel::LOAD_NORMAL) { rv = channel->SetLoadAttributes(loadAttributes); if (NS_FAILED(rv)) return rv; } if (bufferSegmentSize != 0) { rv = channel->SetBufferSegmentSize(bufferSegmentSize); if (NS_FAILED(rv)) return rv; } if (bufferMaxSize != 0) { rv = channel->SetBufferMaxSize(bufferMaxSize); if (NS_FAILED(rv)) return rv; }
nsIInputStream* inStr; rv = channel->OpenInputStream(&inStr); if (NS_FAILED(rv)) return rv;
NS_OpenURI(nsIChannel* *result,            nsIURI* uri,           nsIIOService* ioService = nsnull,    // pass in nsIIOService to optimize callers           nsILoadGroup* loadGroup = nsnull,           nsIInterfaceRequestor* notificationCallbacks = nsnull,           nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIChannel::LOAD_NORMAL),           PRUint32 bufferSegmentSize = 0,            PRUint32 bufferMaxSize = 0){    nsresult rv;    nsCOMPtr<nsIIOService> serv;    if (ioService == nsnull) {        serv = do_GetIOService(&rv);        if (NS_FAILED(rv)) return rv;        ioService = serv.get();    }    nsIChannel* channel = nsnull;    rv = ioService->NewChannelFromURI(uri, &channel);    if (NS_FAILED(rv)) return rv;    if (loadGroup) {        rv = channel->SetLoadGroup(loadGroup);        if (NS_FAILED(rv)) return rv;    }    if (notificationCallbacks) {        rv = channel->SetNotificationCallbacks(notificationCallbacks);        if (NS_FAILED(rv)) return rv;    }    if (loadAttributes != nsIChannel::LOAD_NORMAL) {        rv = channel->SetLoadAttributes(loadAttributes);        if (NS_FAILED(rv)) return rv;    }    if (bufferSegmentSize != 0) {        rv = channel->SetBufferSegmentSize(bufferSegmentSize);        if (NS_FAILED(rv)) return rv;    }    if (bufferMaxSize != 0) {        rv = channel->SetBufferMaxSize(bufferMaxSize);        if (NS_FAILED(rv)) return rv;    }    *result = channel;    return rv;}