Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. StreamHandler.php

function StreamHandler::drain

Drains the source stream into the "sink" client option.

Parameters

string $contentLength Header specifying the amount of: data to read.

Throws

\RuntimeException when the sink option is invalid.

1 call to StreamHandler::drain()
StreamHandler::createResponse in vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php

File

vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php, line 207

Class

StreamHandler
HTTP handler that uses PHP's HTTP stream wrapper.

Namespace

GuzzleHttp\Handler

Code

private function drain(StreamInterface $source, StreamInterface $sink, string $contentLength) : StreamInterface {
    // If a content-length header is provided, then stop reading once
    // that number of bytes has been read. This can prevent infinitely
    // reading from a stream when dealing with servers that do not honor
    // Connection: Close headers.
    Psr7\Utils::copyToStream($source, $sink, \strlen($contentLength) > 0 && (int) $contentLength > 0 ? (int) $contentLength : -1);
    $sink->seek(0);
    $source->close();
    return $sink;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal