Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/zendframework/zendframework#6027-http-response-f…
Browse files Browse the repository at this point in the history
…rom-stream-status-code'

Close zendframework/zendframework#6027
  • Loading branch information
Ocramius committed Apr 2, 2014
2 parents 49d3db4 + 77c7db1 commit 562ad2a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Response/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,11 @@ public static function fromStream($responseString, $stream)

$headerComplete = false;
$headersString = '';
$responseArray = array();

$responseArray = explode("\n", $responseString);
if ($responseString) {
$responseArray = explode("\n", $responseString);
}

while (count($responseArray)) {
$nextLine = array_shift($responseArray);
Expand Down
16 changes: 16 additions & 0 deletions test/Response/ResponseStreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ public function testResponseFactoryFromStringCreatesValidResponse()
$this->assertEquals("Foo Bar\r\nBar Foo", $response->getBody());
}

/**
* @group 6027
*
* @covers \Zend\Http\Response\Stream::fromStream
*/
public function testResponseFactoryFromEmptyStringCreatesValidResponse()
{
$stream = fopen('php://temp','rb+');
fwrite($stream, 'HTTP/1.0 200 OK' . "\r\n\r\n".'Foo Bar'."\r\n".'Bar Foo');
rewind($stream);

$response = Stream::fromStream('', $stream);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals("Foo Bar\r\nBar Foo", $response->getBody());
}

public function testGzipResponse()
{
$stream = fopen(__DIR__ . '/../_files/response_gzip','rb');
Expand Down

0 comments on commit 562ad2a

Please sign in to comment.