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.  
  6. $body = $response->getBody();
  7.  
  8. // Returns false on timeout
  9. $data = $body->read(1024);
  10.  
  11. // Returns false on timeout
  12. $line = fgets($body->detach());