nsresult rv = NS_OK; nsIContentViewer* viewer = nsnull;  nsCOMPtr<nsIURI> aURL; rv = channel->GetURI(getter_AddRefs(aURL)); if (NS_FAILED(rv)) return rv; char* aContentType = nsnull; rv = channel->GetContentType(&aContentType);
nsresult rv; nsCOMPtr<nsIURI> uri; rv = channel->GetURI(getter_AddRefs(uri));
nsDocumentBindInfo::OnStartRequest(nsIChannel* channel, nsISupports *ctxt){    nsresult rv = NS_OK;    nsIContentViewer* viewer = nsnull;    nsCOMPtr<nsIURI> aURL;    rv = channel->GetURI(getter_AddRefs(aURL));    if (NS_FAILED(rv)) return rv;    char* aContentType = nsnull;    rv = channel->GetContentType(&aContentType);    if (NS_FAILED(rv)) return rv;#if defined(DEBUG)    char* spec;    (void)aURL->GetSpec(&spec);    PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,            ("DocumentBindInfo:%p OnStartRequest(...) called for %s.  Content-type is %s\n",            this, spec, aContentType));    nsCRT::free(spec);#endif /* DEBUG */    if (nsnull == m_NextStream) {        /*         * Now that the content type is available, create a document         * (and viewer) of the appropriate type...         */        if (m_DocLoader) {            rv = m_DocLoader->CreateContentViewer(m_Command,                                                   channel,                                                  aContentType,                                                   m_Container,                                                  m_ExtraInfo,                                                  &m_NextStream,                                                   &viewer);        } else {            rv = NS_ERROR_NULL_POINTER;        }        if (NS_FAILED(rv)) {            printf("DocLoaderFactory: Unable to create ContentViewer for command=%s, content-type=%s\n", m_Command ? m_Command : "(null)", aContentType);            if ( m_Container ) {                // Give content container a chance to do something with this URL.                rv = m_Container->HandleUnknownContentType( (nsIDocumentLoader*) m_DocLoader, channel, aContentType, m_Command );            }            // Stop the binding.            // This crashes on Unix/Mac... Stop();            goto done;        }        /*         * Give the document container the new viewer...         */        if (m_Container) {            viewer->SetContainer(m_Container);            rv = m_Container->Embed(viewer, m_Command, m_ExtraInfo);            if (NS_FAILED(rv)) {                goto done;            }        }    }    /*     * Pass the OnStartRequest(...) notification out to the document      * IStreamListener.     */    if (nsnull != m_NextStream) {        rv = m_NextStream->OnStartRequest(channel, ctxt);    }    /* Pass the notification out to the Observer... */    if (nsnull != m_Observer) {        nsresult rv2 = m_Observer->OnStartRequest(channel, ctxt);        if (NS_SUCCEEDED(rv))        	rv = rv2;    }  done:    NS_IF_RELEASE(viewer);    nsCRT::free(aContentType);    return rv;}