read_timeout

Summary

Float describing the timeout to use when reading a streamed body

Types

float

Default

Defaults to the value of the default_socket_timeout PHP ini setting

Constant

GuzzleHttp\RequestOptions::READ_TIMEOUT

The timeout applies to individual read operations on a streamed body (when the stream option is enabled).

  1. $response = $client->request('GET', '/stream', [
  2. 'stream' => true,
  3. 'read_timeout' => 10,
  4. ]);
  5. $body = $response->getBody();
  6. // Returns false on timeout
  7. $data = $body->read(1024);
  8. // Returns false on timeout
  9. $line = fgets($body->detach());