Browse files

[#3498] Minor logic changes

- Cache return of method call -- prevents multiple fetches
- use "null !==" instead of "!is_null" (internal consistency)
  • Loading branch information...
1 parent d567b6f commit 22fd243538731d5459d26bc7a4841fb7f9dc41a7 @weierophinney weierophinney committed Jan 21, 2013
Showing with 6 additions and 5 deletions.
  1. +6 −5 library/Zend/Http/Response/Stream.php
View
11 library/Zend/Http/Response/Stream.php
@@ -203,11 +203,12 @@ public static function fromStream($responseString, $stream)
foreach ($headers as $header) {
if ($header instanceof \Zend\Http\Header\ContentLength) {
$response->setContentLength((int) $header->getFieldValue());
- if (strlen($response->content) > $response->getContentLength()) {
+ $contentLength = $response->getContentLength();
+ if (strlen($response->content) > $contentLength) {
throw new Exception\OutOfRangeException(sprintf(
'Too much content was extracted from the stream (%d instead of %d bytes)',
strlen($response->content),
- $response->getContentLength()
+ $contentLength
));
}
break;
@@ -263,10 +264,10 @@ public function getRawBody()
protected function readStream()
{
$contentLength = $this->getContentLength();
- if (!is_null($contentLength)) {
- $bytes = $contentLength - $this->contentStreamed;
+ if (null !== $contentLength) {
+ $bytes = $contentLength - $this->contentStreamed;
} else {
- $bytes = -1; //Read the whole buffer
+ $bytes = -1; // Read the whole buffer
}
if (!is_resource($this->stream) || $bytes == 0) {

0 comments on commit 22fd243

Please sign in to comment.