Optimize headers parsing

The server can not follow the RFC and use \n as separator instead \r\n
main
Pavel Levin 9 years ago
parent 3c9d9e4efa
commit 6cc26537d8

@ -133,11 +133,11 @@ class Wappalyzer
$headers = trim(substr($response, 0, $headerSize)); $headers = trim(substr($response, 0, $headerSize));
$headers = preg_split('/^\s*$/m', $headers); $headers = preg_split('/^\s*$/m', $headers);
$headers = end($headers); $headers = end($headers);
$lines = array_slice(explode("\r\n", $headers), 1); $lines = array_slice(explode("\n", $headers), 1);
foreach ( $lines as $line ) { foreach ( $lines as $line ) {
if ( strpos(trim($line), ': ') !== false ) { if ( strpos(trim($line), ': ') !== false ) {
list($key, $value) = explode(': ', $line); list($key, $value) = explode(': ', trim($line, "\r"));
$result->headers[strtolower($key)] = $value; $result->headers[strtolower($key)] = $value;
} }

Loading…
Cancel
Save