Skip to content
Permalink
Browse files

Fixing return of values seen as empty in Response.php

  • Loading branch information...
burzum committed Oct 18, 2016
1 parent 605f350 commit 0c0f32f6360b6522bb7a26403c8d830983343f1b
Showing with 16 additions and 3 deletions.
  1. +4 −3 src/Network/Response.php
  2. +12 −0 tests/TestCase/Network/ResponseTest.php
@@ -438,7 +438,7 @@ public function __construct(array $options = [])
}
if (isset($options['stream'])) {
if (!$options['stream'] instanceof StreamInterface) {
throw new InvalidArgumentException('Stream option must be an object implement StreamInterface');
throw new InvalidArgumentException('Stream option must be an object that implements StreamInterface');
}
$this->stream = $options['stream'];
} else {
@@ -741,7 +741,7 @@ public function body($content = null)
if ($content === null) {
$this->stream->rewind();
$result = $this->stream->getContents();
if (empty($result)) {
if (empty($result) && strlen($result) === 0) {
return null;
}
@@ -758,7 +758,7 @@ public function body($content = null)
$this->stream->rewind();
$result = $this->stream->getContents();
if (empty($result)) {
if (empty($result) && strlen($result) === 0) {
return null;
}
@@ -1108,6 +1108,7 @@ public function sharable($public = null, $time = null)
/**
* Sets the Cache-Control s-maxage directive.
*
* The max-age is the number of seconds after which the response should no longer be considered
* a good candidate to be fetched from a shared cache (like in a proxy server).
* If called with no parameters, this function will return the current max-age value if any
@@ -99,6 +99,18 @@ public function testBody()
$response->body('Response body');
$this->assertEquals('Response body', $response->body());
$this->assertEquals('Changed Body', $response->body('Changed Body'));
$response = new Response();
$response->body(0);
$this->assertEquals(0, $response->body());
$response = new Response();
$response->body('0');
$this->assertEquals('0', $response->body());
$response = new Response();
$response->body(null);
$this->assertEquals(null, $response->body());
}
/**

0 comments on commit 0c0f32f

Please sign in to comment.
You can’t perform that action at this time.