nsAutoString	fullURI; fullURI.AssignWithConversion(uristr); if ((fullURI.Find("ftp:
mURI.Assign(uristr); if ((mURI.Find("ftp:
nsHTTPIndexParser::OnStartRequest(nsIChannel* aChannel, nsISupports* aContext){  nsresult rv;  // This should only run once...  if (mContainer) {    // We need to undo the AddRef() on the nsHTTPIndex object that    // happened in nsDirectoryViewerFactory::CreateInstance(). We'll    // stuff it into an nsCOMPtr (because we _know_ it'll get release    // if any errors occur)...    nsCOMPtr<nsIHTTPIndex> httpindex = do_QueryInterface(mHTTPIndex);    // ...and then _force_ a release here    mHTTPIndex->Release();    // Now get the content viewer container's script object.    nsCOMPtr<nsIScriptGlobalObject> scriptGlobal(do_GetInterface(mContainer));    NS_ENSURE_TRUE(scriptGlobal, NS_ERROR_FAILURE);    nsCOMPtr<nsIScriptContext> context;    rv = scriptGlobal->GetContext(getter_AddRefs(context));    NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);    JSContext* jscontext = NS_REINTERPRET_CAST(JSContext*, context->GetNativeContext());    JSObject* global = JS_GetGlobalObject(jscontext);    // Using XPConnect, wrap the HTTP index object...    static NS_DEFINE_CID(kXPConnectCID, NS_XPCONNECT_CID);    NS_WITH_SERVICE(nsIXPConnect, xpc, kXPConnectCID, &rv);    if (NS_FAILED(rv)) return rv;    nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;    rv = xpc->WrapNative(jscontext,                                                global,                         httpindex,                         NS_GET_IID(nsIHTTPIndex),                         getter_AddRefs(wrapper));    NS_ASSERTION(NS_SUCCEEDED(rv), "unable to xpconnect-wrap http-index");    if (NS_FAILED(rv)) return rv;    JSObject* jsobj;    rv = wrapper->GetJSObject(&jsobj);    NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get jsobj from xpconnect wrapper");    if (NS_FAILED(rv)) return rv;    jsval jslistener = OBJECT_TO_JSVAL(jsobj);    // ...and stuff it into the global context    PRBool ok;    ok = JS_SetProperty(jscontext, global, "HTTPIndex", &jslistener);    NS_ASSERTION(ok, "unable to set Listener property");    if (! ok)      return NS_ERROR_FAILURE;  }    // Save off some information about the stream we're about to parse.  rv = aChannel->GetURI(getter_AddRefs(mDirectoryURI));  if (NS_FAILED(rv)) return rv;  nsXPIDLCString uristr;  rv = mDirectoryURI->GetSpec(getter_Copies(uristr));  if (NS_FAILED(rv)) return rv;  // we know that this is a directory (due to being a HTTP-INDEX response)  // so ensure it ends with a slash if its a FTP URL  nsAutoString	fullURI; fullURI.AssignWithConversion(uristr);  if ((fullURI.Find("ftp://", PR_TRUE) == 0) && (fullURI.Last() != (PRUnichar('/'))))  {  	fullURI.AppendWithConversion('/');  }  rv = gRDF->GetUnicodeResource(fullURI.GetUnicode(), getter_AddRefs(mDirectory));  if (NS_FAILED(rv)) return rv;  NS_WITH_SERVICE(nsIRDFContainerUtils, rdfc, "component://netscape/rdf/container-utils", &rv);  if (NS_FAILED(rv)) return rv;  rv = rdfc->MakeSeq(mDataSource, mDirectory, getter_AddRefs(mDirectoryContainer));  if (NS_FAILED(rv)) return rv;  // Mark the directory as "loading"  rv = mDataSource->Assert(mDirectory, kHTTPIndex_Loading, kTrueLiteral, PR_TRUE);  if (NS_FAILED(rv)) return rv;  return NS_OK;}