You are here

public function PumpStream::read in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/psr7/src/PumpStream.php \GuzzleHttp\Psr7\PumpStream::read()

Read data from the stream.

Parameters

int $length Read up to $length bytes from the object and return: them. Fewer than $length bytes may be returned if underlying stream call returns fewer bytes.

Return value

string Returns the data read from the stream, or an empty string if no bytes are available.

Throws

\RuntimeException if an error occurs.

Overrides StreamInterface::read

1 call to PumpStream::read()
PumpStream::getContents in vendor/guzzlehttp/psr7/src/PumpStream.php
Returns the remaining contents in a string

File

vendor/guzzlehttp/psr7/src/PumpStream.php, line 116

Class

PumpStream
Provides a read only stream that pumps data from a PHP callable.

Namespace

GuzzleHttp\Psr7

Code

public function read($length) {
  $data = $this->buffer
    ->read($length);
  $readLen = strlen($data);
  $this->tellPos += $readLen;
  $remaining = $length - $readLen;
  if ($remaining) {
    $this
      ->pump($remaining);
    $data .= $this->buffer
      ->read($remaining);
    $this->tellPos += strlen($data) - $readLen;
  }
  return $data;
}