Skip to content

Commit

Permalink
Base64 encode chunked data before dechunking
Browse files Browse the repository at this point in the history
  • Loading branch information
Warren Seymour committed Nov 14, 2013
1 parent d884ce3 commit ae904d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion net/http/Response.php
Expand Up @@ -406,7 +406,7 @@ protected function _httpChunkedDecode($body) {
if (stripos($this->headers('Transfer-Encoding'), 'chunked') === false) {
return $body;
}
$stream = fopen('data://text/plain,' . $body, 'r');
$stream = fopen('data://text/plain;base64,' . base64_encode($body), 'r');
stream_filter_append($stream, 'dechunk');
return trim(stream_get_contents($stream));
}
Expand Down
11 changes: 11 additions & 0 deletions tests/cases/net/http/ResponseTest.php
Expand Up @@ -390,6 +390,17 @@ public function testTransferEncodingChunkedDecode() {
$response = new Response(compact('message'));
$result = $response->body();
$this->assertEqual($expected, $result);

$expected = '1+1 is 2, 10%40 is 20.';
$message = $headers . join("\r\n", array(
'22',
$expected,
'',
));

$response = new Response(compact('message'));
$result = $response->body();
$this->assertEqual($expected, $result);
}

public function testTypePriority() {
Expand Down

0 comments on commit ae904d3

Please sign in to comment.