Detect the end of a HTTP packet

Kidsduali

New Member
I have the following problem:I have to write a PHP script that works as a client against another HTTP Server. This Server ignores the HTTP Connection:Close header and keeps the TCP connection open unless it is closed by the client. And here is my dilemma. I (the client) have to deciede when a HTTP request/response has finished and then close the connection. Simply use:\[quote\] $data = http://stackoverflow.com/questions/3718158/file_get_contents($url);\[/quote\].. won't work, as file_get_contents returns only if the connection timeout (default 30 seconds) has reached.So I have to write my own read - loop like this (pseudo code):\[code\]$sock = fsockopen(...);$datahttp://stackoverflow.com/questions/3718158/= '';while($line = fgets($sock)) { $data .= $line; if(http_package_recieved()) { break; }}\[/code\]Unfortunately there is no Content-Length header in the response. My question is, how the function \[code\]http_package_recieved()\[/code\]... should look like.Greets Thorsten
 
Back
Top