Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Mar : Re: TidHTTPServer POST Timeout with PHP client

www.cryer.info
Managed Newsgroup Archive

Re: TidHTTPServer POST Timeout with PHP client

Subject:Re: TidHTTPServer POST Timeout with PHP client
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Fri, 2 Mar 2007 16:31:15

"Vern Baker" <javakinetic@gmail.com> wrote in message
news:1172880912.991789.84090@30g2000cwc.googlegroups.com...

> TIdHTTP works against TIdHTTPServer with both GETs and POSTs,
> and works as advertised.  However, PHP POSTs to TIdHTTPServer
> result in timeouts.

Then PHP is likely doing something wrong.

> In IdCustomHTTPServer.pas (line 825), IOHandler.ReadStream will not
> return until a timeout (30 seconds) from the PHP client occurs.

As it should be.  That particular line is telling ReadStream() to wait
for PHP to close the socket.  In order to get to that point, PHP would
not be sending a 'Content-Length' header like it is supposed to.  An
HTTP client cannot POST empty data without that header, and since that
header is obviously not available in this case, there is no other way
for TIdHTTPServer to detect the end of the data being posted.

> At that time, line 825 (latest overnight) is passed out of, and
processing occurs
> with what was POSTed from PHP.   This results in a time exceeded
message
> error on the PHP page.

That is PHP's fault for not telling TIdHTTPServer how to receive the
data correctly in the first place, so TIdHTTPServer sits around doing
nothing until PHP disconnects.

> Does the following POST need to be structured in a particular
> way for Indy to recognize the post stream correctly?

Yes, of course.  You need to specify the actual size of the data being
posted, ie:

    $out = "POST /Data HTTP/1.1\r
";
    $out .= "Host: 127.0.0.1:5048\r
";
    $out .= "Connection: Close\r
";
    $out .= "Content-Length: 0\r
\r
"; // <-- add this!!!


Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive