Extends
lithium\net\http\Message
Accepts an entire HTTP message including headers and body, and parses it into a message body
an array of headers, and the HTTP status.
Parameters
- string $body The full body of the message.
Returns
After parsing out other message components, returns just the message body.Source
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);
if (!$match) {
return trim($body);
}
list($line, $this->version, $code, $message) = $match;
$this->status = compact('code', 'message') + $this->status;
$this->protocol = "HTTP/{$this->version}";
return $body;
}