private function readHeader($fh, $timeout = 5)
{
$header = array();
/* HTTP/SSL connection method */
$http_log = '';
$line = fgets($fh, 4000);
$http_log .= $line;
if (!preg_match('/^HTTP\\/1.1 ([0-9]{0,3}) (.*)\\r\\n$/', $line, $matches)) {
throw new Exception('oSRS Error - UNEXPECTED READ: Unable to parse HTTP response code. Please make sure IP is whitelisted in RWI.');
return false;
}
$header['http_response_code'] = $matches[1];
$header['http_response_text'] = $matches[2];
while ($line != CRLF) {
$line = fgets($fh, 4000);
$http_log .= $line;
if (feof($fh)) {
throw new Exception('oSRS Error - UNEXPECTED READ: Error reading HTTP header.');
return false;
}
$matches = explode(': ', $line, 2);
if (sizeof($matches) == 2) {
$header[trim(strtolower($matches[0]))] = $matches[1];
}
}
$header['full_header'] = $http_log;
return $header;
}