private static function writeRequest(self $response, array $options, ResponseInterface $mock)
    {
        $onProgress = $options['on_progress'] ?? static function () {};
        $response->info += $mock->getInfo() ?: [];

        // simulate "size_upload" if it is set
        if (isset($response->info['size_upload'])) {
            $response->info['size_upload'] = 0.0;
        }

        // simulate "total_time" if it is set
        if (isset($response->info['total_time'])) {
            $response->info['total_time'] = microtime(true) - $response->info['start_time'];
        }

        // "notify" DNS resolution
        $onProgress(0, 0, $response->info);

        // consume the request body
        if (\is_resource($body = $options['body'] ?? '')) {
            $data = stream_get_contents($body);
            if (isset($response->info['size_upload'])) {
                $response->info['size_upload'] += \strlen($data);
            }
        } elseif ($body instanceof \Closure) {
            while ('' !== $data = $body(16372)) {
                if (!\is_string($data)) {
                    throw new TransportException(sprintf('Return value of the "body" option callback must be string, %s returned.', \gettype($data)));
                }

                // "notify" upload progress
                if (isset($response->info['size_upload'])) {
                    $response->info['size_upload'] += \strlen($data);
                }

                $onProgress(0, 0, $response->info);
            }
        }
    }
private static function writeRequest(self $response, array $options, ResponseInterface $mock)
    {
        $onProgress = $options['on_progress'] ?? static function () {};
        $response->info += $mock->getInfo() ?: [];

        // simulate "size_upload" if it is set
        if (isset($response->info['size_upload'])) {
            $response->info['size_upload'] = 0.0;
        }

        // simulate "total_time" if it is set
        if (isset($response->info['total_time'])) {
            $response->info['total_time'] = microtime(true) - $response->info['start_time'];
        }

        // "notify" DNS resolution
        $onProgress(0, 0, $response->info);

        // consume the request body
        if (\is_resource($body = $options['body'] ?? '')) {
            $data = stream_get_contents($body);
            if (isset($response->info['size_upload'])) {
                $response->info['size_upload'] += \strlen($data);
            }
        } elseif ($body instanceof \Closure) {
            while ('' !== $data = $body(16372)) {
                if (!\is_string($data)) {
                    throw new TransportException(sprintf('Return value of the "body" option callback must be string, %s returned.', \gettype($data)));
                }

                // "notify" upload progress
                if (isset($response->info['size_upload'])) {
                    $response->info['size_upload'] += \strlen($data);
                }

                $onProgress(0, 0, $response->info);
            }
        }
    }
private static function writeRequest ( self $ response , array $ options , ResponseInterface $ mock ) { $ onProgress = $ options [ 'on_progress' ] ?? static function ( ) { } ; $ response -> info += $ mock -> getInfo ( ) ? : [ ] ; // simulate "size_upload" if it is set if ( isset ( $ response -> info [ 'size_upload' ] ) ) { $ response -> info [ 'size_upload' ] = 0.0 ; } // simulate "total_time" if it is set if ( isset ( $ response -> info [ 'total_time' ] ) ) { $ response -> info [ 'total_time' ] = microtime ( true ) - $ response -> info [ 'start_time' ] ; } // "notify" DNS resolution $ onProgress ( 0 , 0 , $ response -> info ) ; // consume the request body if ( \ is_resource ( $ body = $ options [ 'body' ] ?? '' ) ) { $ data = stream_get_contents ( $ body ) ; if ( isset ( $ response -> info [ 'size_upload' ] ) ) { $ response -> info [ 'size_upload' ] += \ strlen ( $ data ) ; } } elseif ( $ body instanceof \ Closure ) { while ( '' !== $ data = $ body ( 16372 ) ) { if ( ! \ is_string ( $ data ) ) { throw new TransportException ( sprintf ( 'Return value of the "body" option callback must be string, %s returned.' , \ gettype ( $ data ) ) ) ; } // "notify" upload progress if ( isset ( $ response -> info [ 'size_upload' ] ) ) { $ response -> info [ 'size_upload' ] += \ strlen ( $ data ) ; } $ onProgress ( 0 , 0 , $ response -> info ) ; } } }
Simulates sending the request.
Simulates sending the request .