IdHTTPClient POST problem

Giganews Newsgroups
Subject: IdHTTPClient POST problem
Posted by:  Walters (amit_walt…@yahoo.co.in)
Date: Mon, 12 Apr 2010

Sir I am facing one problem
I created one project (C++Builder 6 & Indy 8.0.25) on which I am sending one formatted string to another server by using IdHTTPClient POST function. It is working fine.
Now I upgraded my project to (C++Builder 2009 & 10.2.5) in which there are many changes like there is no HOST and PORT in IdHTTPClient as it is in Indy 8 when I am trying to use POST Function programme become Non-responding no message send.
My code is like this it is working in (C++Builder 6 & Indy 8.0.25)
bool __fastcall TMainForm::SendXmlToServer(String tXmlData)
{
TStringList *RetXMLValue = new TStringList;
bool RetVal;
int RetMsgCd;
TIdHTTP  *HTTPClient= new TIdHTTP(NULL);
TMemoryStream *Sstream = new  TMemoryStream();

HTTPClient->Host=ServerHost; // not in Indy 10
HTTPClient->Port=ServerPort; // not in indy 10

HTTPClient->Request->Accept=  "*/*";
HTTPClient->Request->AcceptLanguage=  "en-us";
HTTPClient->Request->AcceptEncoding= "gzip, deflate";
HTTPClient->Request->UserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
HTTPClient->Request->Connection="Keep-Alive";
HTTPClient->Request->ContentLength= tXmlData.Length();

RetXMLValue->Text= tXmlData;

try
{

Sstream->Position=0;
HTTPClient->Post("http://"+ServerHost+":"+IntToStr(ServerPort),RetXMLValue,Sstream);
Sstream->Position=0;
RetXMLValue->LoadFromStream(Sstream);

  delete HTTPClient;
  delete Sstream;
  delete RetXMLValue;
  RetVal=true;
  }
catch(...)
{
RetVal=false;
}
}

Replies