public function ReadLimitEntityBody::read

@codeCoverageIgnore

Overrides AbstractEntityBodyDecorator::read

File

drupal/core/vendor/guzzle/http/Guzzle/Http/ReadLimitEntityBody.php, line 105

Class

ReadLimitEntityBody
EntityBody decorator used to return only a subset of an entity body

Namespace

Guzzle\Http

Code

public function read($length) {

  // Check if the current position is less than the total allowed bytes + original offset
  $remaining = $this->offset + $this->limit - $this->body
    ->ftell();
  if ($remaining > 0) {

    // Only return the amount of requested data, ensuring that the byte limit is not exceeded
    return $this->body
      ->read(min($remaining, $length));
  }
  else {
    return false;
  }
}