Extends
lithium\net\http\Message
Decodes content bodies transferred with HTTP chunked encoding.
Parameters
- string $body A chunked HTTP message body.
Returns
string Returns the value of `$body` with chunks decoded, but only if the value of the `Transfer-Encoding` header is set to `'chunked'`. Otherwise, returns `$body` unmodified.Source
protected function _httpChunkedDecode($body) {
if (stripos($this->headers['Transfer-Encoding'], 'chunked') === false) {
return $body;
}
$stream = fopen('data://text/plain,' . $body, 'r');
stream_filter_append($stream, 'dechunk');
return trim(stream_get_contents($stream));
}