if (NS_SUCCEEDED(rv = NS_NewURI(getter_AddRefs(url), nsCAutoString(action))))
if (NS_SUCCEEDED(rv = NS_NewURI(getter_AddRefs(url), actionStr)))
InternetSearchDataSource::DoSearch(nsIRDFResource *source, nsIRDFResource *engine, nsString text){	nsresult	rv;	if (!source)		return(NS_ERROR_NULL_POINTER);	if (!engine)		return(NS_ERROR_NULL_POINTER);	if (!mInner)	{		return(NS_RDF_NO_VALUE);	}	// get data	nsAutoString		data("");	nsCOMPtr<nsIRDFNode>	dataTarget = nsnull;	if (NS_SUCCEEDED((rv = mInner->GetTarget(engine, kNC_Data, PR_TRUE, getter_AddRefs(dataTarget)))) && (dataTarget))	{		nsCOMPtr<nsIRDFLiteral>	dataLiteral = do_QueryInterface(dataTarget);		if (!dataLiteral)			return(rv);		PRUnichar	*dataUni;		if (NS_FAILED(rv = dataLiteral->GetValue(&dataUni)))			return(rv);		data = dataUni;	}	else	{		const char	*engineURI = nsnull;		if (NS_FAILED(rv = engine->GetValueConst(&engineURI)))			return(rv);		nsAutoString	engineStr(engineURI);		if (engineStr.Find(kEngineProtocol) != 0)			return(rv);		engineStr.Cut(0, sizeof(kEngineProtocol) - 1);		char	*baseFilename = engineStr.ToNewCString();		if (!baseFilename)			return(rv);		baseFilename = nsUnescape(baseFilename);		if (!baseFilename)			return(rv);		nsFileSpec	engineSpec(baseFilename);		rv = ReadFileContents(engineSpec, data);//		rv = NS_ERROR_UNEXPECTED;			// XXX rjc: fix this		nsCRT::free(baseFilename);		baseFilename = nsnull;		if (NS_FAILED(rv))		{			return(rv);		}		// save file contents		nsCOMPtr<nsIRDFLiteral>	dataLiteral;		if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(data.GetUnicode(), getter_AddRefs(dataLiteral))))		{			if (mInner)			{				mInner->Assert(engine, kNC_Data, dataLiteral, PR_TRUE);			}		}	}	if (data.Length() < 1)		return(NS_RDF_NO_VALUE);		nsAutoString	action, method, input;	if (NS_FAILED(rv = GetData(data, "search", "action", action)))		return(rv);	if (NS_FAILED(rv = GetData(data, "search", "method", method)))		return(rv);	if (NS_FAILED(rv = GetInputs(data, text, input)))		return(rv);#ifdef	DEBUG_SEARCH_OUTPUT	char *cAction = action.ToNewCString();	char *cMethod = method.ToNewCString();	char *cInput = input.ToNewCString();	printf("Search Action: '%s'\n", cAction);	printf("Search Method: '%s'\n", cMethod);	printf(" Search Input: '%s'\n\n", cInput);	if (cAction)	{		nsCRT::free(cAction);		cAction = nsnull;	}	if (cMethod)	{		nsCRT::free(cMethod);		cMethod = nsnull;	}	if (cInput)	{		nsCRT::free(cInput);		cInput = nsnull;	}#endif	if (input.Length() < 1)		return(NS_ERROR_UNEXPECTED);	if (method.EqualsIgnoreCase("get"))	{		// HTTP Get method support		action += "?";		action += input;	}	nsCOMPtr<nsIInternetSearchContext>	context;	if (NS_FAILED(rv = NS_NewInternetSearchContext(source, engine, getter_AddRefs(context))))		return(rv);	if (!context)	return(NS_ERROR_UNEXPECTED);	nsCOMPtr<nsIURI>	url;	if (NS_SUCCEEDED(rv = NS_NewURI(getter_AddRefs(url), nsCAutoString(action))))	{		nsCOMPtr<nsIChannel>	channel;		// XXX: Null LoadGroup ?		if (NS_SUCCEEDED(rv = NS_OpenURI(getter_AddRefs(channel), url, nsnull)))		{			if (method.EqualsIgnoreCase("post"))			{				nsCOMPtr<nsIHTTPChannel>	httpChannel = do_QueryInterface(channel);				if (httpChannel)				{					httpChannel->SetRequestMethod(HM_POST);			        	// construct post data to send			        	nsAutoString	postStr(POSTHEADER_PREFIX);			        	postStr.Append(input.Length(), 10);			        	postStr += POSTHEADER_SUFFIX;			        	postStr += input;			        						nsCOMPtr<nsIInputStream>	postDataStream;					if (NS_SUCCEEDED(rv = NS_NewPostDataStream(PR_FALSE, nsCAutoString(postStr),						0, getter_AddRefs(postDataStream))))					{						httpChannel->SetPostDataStream(postDataStream);					}				}			}			if (NS_SUCCEEDED(rv = channel->AsyncRead(0, -1, context, this)))			{				if (mConnections)				{					mConnections->AppendElement(channel);				}			}		}	}	// dispose of any last HTML results page	if (mInner)	{		nsCOMPtr<nsIRDFNode>	htmlNode;		if (NS_SUCCEEDED(rv = mInner->GetTarget(engine, kNC_HTML, PR_TRUE, getter_AddRefs(htmlNode)))			&& (rv != NS_RDF_NO_VALUE))		{			rv = mInner->Unassert(engine, kNC_HTML, htmlNode);		}	}	// start "loading" animation for this search engine	if (NS_SUCCEEDED(rv) && (mInner))	{		// remove status icon so that loading icon style can be used		nsCOMPtr<nsIRDFNode>		engineIconNode = nsnull;		mInner->GetTarget(engine, kNC_StatusIcon, PR_TRUE, getter_AddRefs(engineIconNode));		if (engineIconNode)		{			rv = mInner->Unassert(engine, kNC_StatusIcon, engineIconNode);		}		nsCOMPtr<nsIRDFLiteral>	literal;		if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(nsAutoString("true").GetUnicode(), getter_AddRefs(literal))))		{			mInner->Assert(engine, kNC_loading, literal, PR_TRUE);		}	}	return(rv);}