nsAutoString	encodingStr, resultEncodingStr;
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, userVar, text, input)))	return(rv); if (input.Length() < 1)				return(NS_ERROR_UNEXPECTED);
InternetSearchDataSource::DoSearch(nsIRDFResource *source, nsIRDFResource *engine,				const nsString &fullURL, const nsString &text){	nsresult	rv;	nsAutoString	textTemp(text);	if (!mInner)	return(NS_RDF_NO_VALUE);//	Note: source can be null//	if (!source)	return(NS_ERROR_NULL_POINTER);	if (!engine)	return(NS_ERROR_NULL_POINTER);	validateEngine(engine);	nsCOMPtr<nsIUnicodeDecoder>	unicodeDecoder;	nsAutoString			action, methodStr, input, userVar;	nsCOMPtr<nsIRDFLiteral>		dataLit;	if (NS_FAILED(rv = FindData(engine, getter_AddRefs(dataLit))) ||		(rv == NS_RDF_NO_VALUE))	return(rv);	const PRUnichar			*dataUni = nsnull;	dataLit->GetValueConst(&dataUni);	if (!dataUni)			return(NS_RDF_NO_VALUE);	if (!fullURL.IsEmpty())	{		action.Assign(fullURL);		methodStr.AssignLiteral("get");	}	else	{		if (NS_FAILED(rv = GetData(dataUni, "search", 0, "action", action)))	return(rv);		if (NS_FAILED(rv = GetData(dataUni, "search", 0, "method", methodStr)))	return(rv);	}	nsAutoString	encodingStr, resultEncodingStr;	// first look for "interpret/charset"... if that isn't specified,	// then fall back to looking for "interpret/resultEncoding" (a decimal)	GetData(dataUni, "interpret", 0, "charset", resultEncodingStr);	if (resultEncodingStr.IsEmpty())	{		GetData(dataUni, "interpret", 0, "resultEncoding", encodingStr);	// decimal string values		MapEncoding(encodingStr, resultEncodingStr);	}	// rjc note: ignore "interpret/resultTranslationEncoding" as well as	// "interpret/resultTranslationFont" since we always convert results to Unicode	if (!resultEncodingStr.IsEmpty())	{		nsCOMPtr <nsICharsetConverterManager> charsetConv = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);		if (NS_SUCCEEDED(rv))		{                  NS_LossyConvertUCS2toASCII charset(resultEncodingStr);                  rv = charsetConv->GetUnicodeDecoder(charset.get(),                                                      getter_AddRefs(unicodeDecoder));		}	}	// first look for "search/queryCharset"... if that isn't specified,	// then fall back to looking for "search/queryEncoding" (a decimal)	nsAutoString    queryEncodingStr;	GetData(dataUni, "search", 0, "queryCharset", queryEncodingStr);	if (queryEncodingStr.IsEmpty())	{		GetData(dataUni, "search", 0, "queryEncoding", encodingStr);		// decimal string values		MapEncoding(encodingStr, queryEncodingStr);	}	if (!queryEncodingStr.IsEmpty())	{		// convert from escaped-UTF_8, to unicode, and then to		// the charset indicated by the dataset in question		char	*utf8data = ToNewUTF8String(textTemp);		if (utf8data)		{			nsCOMPtr<nsITextToSubURI> textToSubURI = 			         do_GetService(kTextToSubURICID, &rv);			if (NS_SUCCEEDED(rv) && (textToSubURI))			{				PRUnichar	*uni = nsnull;				if (NS_SUCCEEDED(rv = textToSubURI->UnEscapeAndConvert("UTF-8", utf8data, &uni)) && (uni))				{					char		*charsetData = nsnull;					nsCAutoString	queryencodingstrC;					queryencodingstrC.AssignWithConversion(queryEncodingStr);					if (NS_SUCCEEDED(rv = textToSubURI->ConvertAndEscape(queryencodingstrC.get(), uni, &charsetData))					        && (charsetData))					{						textTemp.AssignWithConversion(charsetData);						Recycle(charsetData);					}					Recycle(uni);				}			}			Recycle(utf8data);		}	}	if (fullURL.IsEmpty() && methodStr.LowerCaseEqualsLiteral("get"))	{    nsAutoString engineNameStr;  	GetData(dataUni, "search", 0, "name", engineNameStr);    if (NS_FAILED(rv = GetInputs(dataUni, engineNameStr, userVar, textTemp, input, 0, 0, 0)))  return(rv);		if (input.IsEmpty())				return(NS_ERROR_UNEXPECTED);		// HTTP Get method support		action += NS_LITERAL_STRING("?") + input;	}	nsCOMPtr<nsIInternetSearchContext>	context;	if (NS_FAILED(rv = NS_NewInternetSearchContext(nsIInternetSearchContext::WEB_SEARCH_CONTEXT,		source, engine, unicodeDecoder, nsnull, getter_AddRefs(context))))		return(rv);	if (!context)	return(NS_ERROR_UNEXPECTED);	nsCOMPtr<nsIURI>	url;	if (NS_SUCCEEDED(rv = NS_NewURI(getter_AddRefs(url), action)))	{		nsCOMPtr<nsIChannel>	channel;		if (NS_SUCCEEDED(rv = NS_NewChannel(getter_AddRefs(channel), url, nsnull, mLoadGroup)))		{			// send a "MultiSearch" header			nsCOMPtr<nsIHttpChannel> httpMultiChannel (do_QueryInterface(channel));			if (httpMultiChannel)			{                httpMultiChannel->SetRequestHeader(NS_LITERAL_CSTRING("MultiSearch"),                                                   NS_LITERAL_CSTRING("true"),                                                   PR_FALSE);			}			// get it just from the cache if we can (do not validate)			channel->SetLoadFlags(nsIRequest::LOAD_FROM_CACHE);			if (methodStr.LowerCaseEqualsLiteral("post"))			{				nsCOMPtr<nsIHttpChannel> httpChannel (do_QueryInterface(channel));				if (httpChannel)				{				    httpChannel->SetRequestMethod(NS_LITERAL_CSTRING("POST"));				    				    // construct post data to send				    nsAutoString	postStr;				    postStr.AssignASCII(POSTHEADER_PREFIX);				    postStr.AppendInt(input.Length(), 10);				    postStr.AppendASCII(POSTHEADER_SUFFIX);				    postStr += input;				    				    nsCOMPtr<nsIInputStream>	postDataStream;				    nsCAutoString			poststrC;				    poststrC.AssignWithConversion(postStr);				    if (NS_SUCCEEDED(rv = NS_NewPostDataStream(getter_AddRefs(postDataStream),									       PR_FALSE, poststrC, 0)))				    {					nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(httpChannel));					NS_ASSERTION(uploadChannel, "http must support nsIUploadChannel");					uploadChannel->SetUploadStream(postDataStream, EmptyCString(), -1);				    }				}			}						nsCOMPtr<nsIRequest> request;      rv = channel->AsyncOpen(this, context);		}	}	// 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);		}		mInner->Assert(engine, kNC_loading, kTrueLiteral, PR_TRUE);	}	return(rv);}