Skip to content

Commit caf9e48

Browse files
committed
Fix response header splitting to allow double CRLF in response body
1 parent 026987c commit caf9e48

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### 1.0.1 (2013-03
2+
3+
* Bugfix: Allow double CRLF in response body
4+
5+
### 1.0.0 (2013-03-11)
6+
7+
* Initial release

src/Igorw/CgiHttpKernel/CgiHttpKernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ
6767
$process->start();
6868
$process->wait();
6969

70-
list($headerList, $body) = explode("\r\n\r\n", $process->getOutput());
70+
list($headerList, $body) = explode("\r\n\r\n", $process->getOutput(), 2);
7171
$headers = $this->getHeaderMap(explode("\r\n", $headerList));
7272
unset($headers['Cookie']);
7373

tests/functional/CgiHttpKernelTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,14 @@ public function attributesShouldBeSerializedToEnv()
248248
$expected = json_encode($attributes);
249249
$this->assertSame($expected, $response->getContent());
250250
}
251+
252+
/** @test */
253+
public function doubleCrlfResponseBodyShouldBeDecodedProperly()
254+
{
255+
$request = Request::create('/double-crlf-response-body.php');
256+
$response = $this->kernel->handle($request);
257+
258+
$expected = "foo\r\n\r\nbar";
259+
$this->assertSame($expected, $response->getContent());
260+
}
251261
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
echo "foo\r\n\r\nbar";

0 commit comments

Comments
 (0)