Exemplo n.º 1
0
 private static function parseResult($result, $url)
 {
     $pos = strpos($result, "\r\n\r\n");
     $content = substr($result, $pos + 4);
     $headerLines = explode("\r\n", substr($result, 0, $pos));
     preg_match('/\\d{3}/', array_shift($headerLines), $matches);
     if (!isset($matches[0])) {
         throw new DownloadFailureException($url, 'Server didn\'t return response code');
     }
     $code = intval($matches[0]);
     $headers = HttpHeadersHelper::parseHeaderLines($headerLines);
     return new Document($url, $code, $headers, $content);
 }