private function readData(&$fh, $timeout = 5)
{
$len = 0;
/* PHP doesn't have timeout for fread ... we just set the timeout for the socket */
socket_set_timeout($fh, $timeout);
$header = $this->readHeader($fh, $timeout);
if (!$header || !isset($header['content-length']) || empty($header['content-length'])) {
throw new Exception('oSRS Error - UNEXPECTED ERROR: No Content-Length header provided! Please make sure IP is whitelisted in RWI.');
}
$len = (int) $header['content-length'];
$line = '';
while (strlen($line) < $len) {
$line .= fread($fh, $len);
if ($this->_opsHandler->socketStatus($fh)) {
return false;
}
}
if ($line) {
$buf = $line;
} else {
$buf = false;
}
$this->close_socket();
return $buf;
}