protected function _parseMessage($body)
{
if (!($parts = explode("\r\n\r\n", $body, 2)) || count($parts) === 1) {
return trim($body);
}
list($headers, $body) = $parts;
$headers = str_replace("\r", "", explode("\n", $headers));
if (array_filter($headers) === array()) {
return trim($body);
}
preg_match('/HTTP\\/(\\d+\\.\\d+)\\s+(\\d+)(?:\\s+(.*))?/i', array_shift($headers), $match);
$this->headers($headers, false);
if (!$match) {
return trim($body);
}
list($line, $this->version, $code) = $match;
if (isset($this->_statuses[$code])) {
$message = $this->_statuses[$code];
}
if (isset($match[3])) {
$message = $match[3];
}
$this->status = compact('code', 'message') + $this->status;
$this->protocol = "HTTP/{$this->version}";
return $body;
}