Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/kuwabarahiroshi/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Sep 4, 2012
2 parents ef90275 + d2cfcce commit b5f1a44
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Zend/Http/Response.php
Expand Up @@ -180,7 +180,7 @@ public static function fromString($string)


$response = new static(); $response = new static();


$regex = '/^HTTP\/(?P<version>1\.[01]) (?P<status>\d{3})(?:[ ]+(?P<reason>.+))?$/'; $regex = '/^HTTP\/(?P<version>1\.[01]) (?P<status>\d{3})(?:[ ]+(?P<reason>.*))?$/';
$matches = array(); $matches = array();
if (!preg_match($regex, $firstLine, $matches)) { if (!preg_match($regex, $firstLine, $matches)) {
throw new Exception\InvalidArgumentException( throw new Exception\InvalidArgumentException(
Expand Down
15 changes: 15 additions & 0 deletions tests/ZendTest/Http/ResponseTest.php
Expand Up @@ -73,6 +73,21 @@ public function testResponseEndsAtStatusCode()
$this->assertEquals('Foo Bar', $response->getContent()); $this->assertEquals('Foo Bar', $response->getContent());
} }


public function testResponseHasZeroLengthReasonPhrase()
{
// Space after status code is mandatory,
// though, reason phrase can be empty.
// @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1
$string = 'HTTP/1.0 200 ' . "\r\n\r\n" . 'Foo Bar';

$response = Response::fromString($string);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('Foo Bar', $response->getContent());

// Reason phrase would fallback to default reason phrase.
$this->assertEquals('OK', $response->getReasonPhrase());
}

public function testGzipResponse () public function testGzipResponse ()
{ {
$response_text = file_get_contents(__DIR__ . '/_files/response_gzip'); $response_text = file_get_contents(__DIR__ . '/_files/response_gzip');
Expand Down

0 comments on commit b5f1a44

Please sign in to comment.