protected function parseHeaders()
{
if (null !== $this->header) {
$headers = explode("\n", $this->header);
foreach ($headers as $header) {
if (strpos($header, 'HTTP') !== false) {
$this->version = substr($header, 0, strpos($header, ' '));
$this->version = substr($this->version, strpos($this->version, '/') + 1);
preg_match('/\\d\\d\\d/', trim($header), $match);
$this->code = $match[0];
$this->message = trim(str_replace('HTTP/' . $this->version . ' ' . $this->code . ' ', '', $header));
} else {
if (strpos($header, ':') !== false) {
$name = substr($header, 0, strpos($header, ':'));
$value = substr($header, strpos($header, ':') + 1);
$this->headers[trim($name)] = trim($value);
}
}
}
}
}