if (method.EqualsIgnoreCase("post"))
if (methodStr.EqualsIgnoreCase("post"))
InternetSearchDataSource::DoSearch(nsIRDFResource *source, nsIRDFResource *engine,				const nsString &fullURL, const nsString &text){	nsresult	rv;	nsAutoString	textTemp(text);//	Note: source can be null//	if (!source)	return(NS_ERROR_NULL_POINTER);	if (!engine)	return(NS_ERROR_NULL_POINTER);	if (!mInner)	return(NS_RDF_NO_VALUE);	nsCOMPtr<nsIUnicodeDecoder>	unicodeDecoder;	nsAutoString			action, method, 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.Length() > 0)	{		action.Assign(fullURL);		method.AssignWithConversion("get");	}	else	{		if (NS_FAILED(rv = GetData(dataUni, "search", 0, "action", action)))	return(rv);		if (NS_FAILED(rv = GetData(dataUni, "search", 0, "method", method)))	return(rv);	}	nsAutoString	encodingStr, queryEncodingStr, 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.Length() < 1)	{		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.Length() > 0)	{		NS_WITH_SERVICE(nsICharsetConverterManager, charsetConv,			kCharsetConverterManagerCID, &rv);		if (NS_SUCCEEDED(rv) && (charsetConv))		{			rv = charsetConv->GetUnicodeDecoder(&resultEncodingStr,				getter_AddRefs(unicodeDecoder));		}	}	GetData(dataUni, "search", 0, "queryEncoding", encodingStr);		// decimal string values	MapEncoding(encodingStr, queryEncodingStr);	if (queryEncodingStr.Length() > 0)	{		// convert from escaped-UTF_8, to unicode, and then to		// the charset indicated by the dataset in question		char	*utf8data = textTemp.ToNewUTF8String();		if (utf8data)		{			NS_WITH_SERVICE(nsITextToSubURI, textToSubURI,				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, uni, &charsetData)) && (charsetData))					{						textTemp.AssignWithConversion(charsetData);						Recycle(charsetData);					}					Recycle(uni);				}			}			Recycle(utf8data);		}	}	if (fullURL.Length() > 0)	{	}	else if (method.EqualsIgnoreCase("get"))	{		if (NS_FAILED(rv = GetInputs(dataUni, userVar, textTemp, input)))	return(rv);		if (input.Length() < 1)				return(NS_ERROR_UNEXPECTED);		// HTTP Get method support		action.AppendWithConversion("?");		action += 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_OpenURI(getter_AddRefs(channel), url, nsnull, mLoadGroup)))		{			// send a "MultiSearch" header			nsCOMPtr<nsIHTTPChannel>	httpMultiChannel = do_QueryInterface(channel);			if (httpMultiChannel)			{				nsCOMPtr<nsIAtom>	multiSearchAtom = getter_AddRefs(NS_NewAtom("MultiSearch"));				if (multiSearchAtom)				{					httpMultiChannel->SetRequestHeader(multiSearchAtom, "true");				}			}			// get it just from the cache if we can (do not validate)			channel->SetLoadAttributes(nsIChannel::VALIDATE_NEVER);			if (method.EqualsIgnoreCase("post"))			{				nsCOMPtr<nsIHTTPChannel>	httpChannel = do_QueryInterface(channel);				if (httpChannel)				{					nsCOMPtr<nsIAtom> method = NS_NewAtom ("POST");					httpChannel->SetRequestMethod(method);			        	// construct post data to send			        	nsAutoString	postStr;			        	postStr.AssignWithConversion(POSTHEADER_PREFIX);			        	postStr.AppendInt(input.Length(), 10);			        	postStr.AppendWithConversion(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)))					{						httpChannel->SetUploadStream(postDataStream);					}				}			}			if (NS_SUCCEEDED(rv = channel->AsyncRead(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);		}		nsCOMPtr<nsIRDFLiteral>	literal;		if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(NS_ConvertASCIItoUCS2("true").GetUnicode(), getter_AddRefs(literal))))		{			mInner->Assert(engine, kNC_loading, literal, PR_TRUE);		}	}	return(rv);}