Skip to content
Snippets Groups Projects

Resolve "use multi curl to improve performance"

Merged Ghost User requested to merge 19-use-multi-curl-to-improve-performance into master
1 file
+ 28
0
Compare changes
  • Side-by-side
  • Inline
+ 28
0
<?php
namespace app\Models;
class HttpParser
{
public static function parseHeader($headerPart){
$headerLine = explode("\r\n", $headerPart);
$httpcode = rtrim($headerLine[0]);
$httpcode = explode(" ", $httpcode);
$header['http_code'] = $httpcode[1];
foreach($headerLine as $line) {
if(stripos($line, ": ")) {
$tmp = explode(": ", $line);
$header[$tmp[0]] = $tmp[1];
}
}
return $header;
}
public static function parse($htmldoc){
$parts = explode("\r\n\r\n", $htmldoc);
$out['header'] = self::parseHeader($parts[count($parts)-2]);
$out['data'] = $parts[count($parts)-1];
return $out;
}
}
\ No newline at end of file
Loading