Hi All,
I've been trying to retrieve HTTP response data using the following:
while(!feof){
$response[i++]=fgets($socket);
}
However this only allows me to get the data line by line. Unfortunately this method retrieves the header information before getting the actual data that I need in the HTTP response (i.e. the 'body'). Is there any way that I can retrieve the 'body' directly without having to read the header information first?
Thanks.
How to get HTTP response body without headers
Moderator: General Moderators
after the headerst a \r\n is required. so you could read-and-skip untill there...
Code: Select all
// skip to end of headers
$skip = true;
while (!feof($fp) && $skip)
{
$line = fgets($fp);
if ($line == "\r\n")
{
$skip = false;
}
}
// now you can read to feof