original_string: private static function readResponse(self $response, array $options, ResponseInterface $mock, int &$offset)
      {
          $onProgress = $options['on_progress'] ?? static function () {};
  
          // populate info related to headers
          $info = $mock->getInfo() ?: [];
          $response->info['http_code'] = ($info['http_code'] ?? 0) ?: $mock->getStatusCode(false) ?: 200;
          $response->addResponseHeaders($info['response_headers'] ?? [], $response->info, $response->headers);
          $dlSize = isset($response->headers['content-encoding']) ? 0 : (int) ($response->headers['content-length'][0] ?? 0);
  
          $response->info = [
              'start_time' => $response->info['start_time'],
              'user_data' => $response->info['user_data'],
              'http_code' => $response->info['http_code'],
          ] + $info + $response->info;
  
          if (isset($response->info['total_time'])) {
              $response->info['total_time'] = microtime(true) - $response->info['start_time'];
          }
  
          // "notify" headers arrival
          $onProgress(0, $dlSize, $response->info);
  
          // cast response body to activity list
          $body = $mock instanceof self ? $mock->body : $mock->getContent(false);
  
          if (!\is_string($body)) {
              foreach ($body as $chunk) {
                  if ('' === $chunk = (string) $chunk) {
                      // simulate a timeout
                      $response->body[] = new ErrorChunk($offset);
                  } else {
                      $response->body[] = $chunk;
                      $offset += \strlen($chunk);
                      // "notify" download progress
                      $onProgress($offset, $dlSize, $response->info);
                  }
              }
          } elseif ('' !== $body) {
              $response->body[] = $body;
              $offset = \strlen($body);
          }
  
          if (isset($response->info['total_time'])) {
              $response->info['total_time'] = microtime(true) - $response->info['start_time'];
          }
  
          // "notify" completion
          $onProgress($offset, $dlSize, $response->info);
  
          if ($dlSize && $offset !== $dlSize) {
              throw new TransportException(sprintf('Transfer closed with %s bytes remaining to read.', $dlSize - $offset));
          }
      }
code: private static function readResponse(self $response, array $options, ResponseInterface $mock, int &$offset)
      {
          $onProgress = $options['on_progress'] ?? static function () {};
  
          // populate info related to headers
          $info = $mock->getInfo() ?: [];
          $response->info['http_code'] = ($info['http_code'] ?? 0) ?: $mock->getStatusCode(false) ?: 200;
          $response->addResponseHeaders($info['response_headers'] ?? [], $response->info, $response->headers);
          $dlSize = isset($response->headers['content-encoding']) ? 0 : (int) ($response->headers['content-length'][0] ?? 0);
  
          $response->info = [
              'start_time' => $response->info['start_time'],
              'user_data' => $response->info['user_data'],
              'http_code' => $response->info['http_code'],
          ] + $info + $response->info;
  
          if (isset($response->info['total_time'])) {
              $response->info['total_time'] = microtime(true) - $response->info['start_time'];
          }
  
          // "notify" headers arrival
          $onProgress(0, $dlSize, $response->info);
  
          // cast response body to activity list
          $body = $mock instanceof self ? $mock->body : $mock->getContent(false);
  
          if (!\is_string($body)) {
              foreach ($body as $chunk) {
                  if ('' === $chunk = (string) $chunk) {
                      // simulate a timeout
                      $response->body[] = new ErrorChunk($offset);
                  } else {
                      $response->body[] = $chunk;
                      $offset += \strlen($chunk);
                      // "notify" download progress
                      $onProgress($offset, $dlSize, $response->info);
                  }
              }
          } elseif ('' !== $body) {
              $response->body[] = $body;
              $offset = \strlen($body);
          }
  
          if (isset($response->info['total_time'])) {
              $response->info['total_time'] = microtime(true) - $response->info['start_time'];
          }
  
          // "notify" completion
          $onProgress($offset, $dlSize, $response->info);
  
          if ($dlSize && $offset !== $dlSize) {
              throw new TransportException(sprintf('Transfer closed with %s bytes remaining to read.', $dlSize - $offset));
          }
      }
code_tokens: private static function readResponse ( self $ response , array $ options , ResponseInterface $ mock , int & $ offset ) { $ onProgress = $ options [ 'on_progress' ] ?? static function ( ) { } ; // populate info related to headers $ info = $ mock -> getInfo ( ) ? : [ ] ; $ response -> info [ 'http_code' ] = ( $ info [ 'http_code' ] ?? 0 ) ? : $ mock -> getStatusCode ( false ) ? : 200 ; $ response -> addResponseHeaders ( $ info [ 'response_headers' ] ?? [ ] , $ response -> info , $ response -> headers ) ; $ dlSize = isset ( $ response -> headers [ 'content-encoding' ] ) ? 0 : ( int ) ( $ response -> headers [ 'content-length' ] [ 0 ] ?? 0 ) ; $ response -> info = [ 'start_time' => $ response -> info [ 'start_time' ] , 'user_data' => $ response -> info [ 'user_data' ] , 'http_code' => $ response -> info [ 'http_code' ] , ] + $ info + $ response -> info ; if ( isset ( $ response -> info [ 'total_time' ] ) ) { $ response -> info [ 'total_time' ] = microtime ( true ) - $ response -> info [ 'start_time' ] ; } // "notify" headers arrival $ onProgress ( 0 , $ dlSize , $ response -> info ) ; // cast response body to activity list $ body = $ mock instanceof self ? $ mock -> body : $ mock -> getContent ( false ) ; if ( ! \ is_string ( $ body ) ) { foreach ( $ body as $ chunk ) { if ( '' === $ chunk = ( string ) $ chunk ) { // simulate a timeout $ response -> body [ ] = new ErrorChunk ( $ offset ) ; } else { $ response -> body [ ] = $ chunk ; $ offset += \ strlen ( $ chunk ) ; // "notify" download progress $ onProgress ( $ offset , $ dlSize , $ response -> info ) ; } } } elseif ( '' !== $ body ) { $ response -> body [ ] = $ body ; $ offset = \ strlen ( $ body ) ; } if ( isset ( $ response -> info [ 'total_time' ] ) ) { $ response -> info [ 'total_time' ] = microtime ( true ) - $ response -> info [ 'start_time' ] ; } // "notify" completion $ onProgress ( $ offset , $ dlSize , $ response -> info ) ; if ( $ dlSize && $ offset !== $ dlSize ) { throw new TransportException ( sprintf ( 'Transfer closed with %s bytes remaining to read.' , $ dlSize - $ offset ) ) ; } }
docstring: Simulates reading the response.
docstring_tokens: Simulates reading the response .