Title: Message

I have an application that must communicate with a server via the Internet using HTTP. (I have no choice in this). Using the Indy TIdHTTP component I perform the following:

 

Function CommViaHTTP(PostData : string) : boolean;

var

  Source: TStringList;

  Response: TStringStream;

  strTemp : String;

begin

  HTTP.ProxyParams.ProxyServer := '';

  HTTP.ProxyParams.ProxyPort := 80;

  HTTP.Request.ContentType := 'application/x-www-form-urlencoded';

 

  Response := TStringStream.Create('');

  try

    Source := TStringList.Create;

    try

     Source.Add(PostData);

     try

       strTemp := MainForm.AppSettings.StoredValues.StoredValue['WebSiteUrl'];

       HTTP.Post(strTemp, Source, Response);

     except

      DebugLog('Server Response: ' + Response.DataString);

      Result := False;

      Exit;

     end;

 

     DebugLog('Data posted to the Server: ' + PostData);

     DebugLog('Server Responded with: ' + Response.DataString);

 

    finally

     Source.Free;

    end;

  finally

    Response.Free;

  end;

end;

 

I pulled this code from another module I am maintaining and it works every time. When I first copied the code over to this new module I tested it and never got a response from the server. I spent several hours in the office this weekend trying to find my problem, and to get this to work for me in my code (as presented above). The thing is it seems to work occasionally. That is over a 4 hour testing period yesterday, I actually got a response back from the server after the HTTP.Post method was called. It worked twice, but failed about 10 times. *arggh*

 

The code in the original module is essentially the same, but works perfectly every time.

 

Can anyone see what it is that I might be doing wrong here? I am a beginner with Indy and HHPT via application programming. Although I have a decade of hardcore sockets experience under my belt.

 

Help!

 

Eric

 

Eric Tishler

Software Architect

Resolute Partners, LLC

Phone: 203.271.1122

Fax: 203.271.1460

[EMAIL PROTECTED]

 

_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to