Driver Options

Guzzle supports a variety of request optionsopen in new window, some of which are directly available in the Http Client. In this section, settings or removing such options is briefly illustrated.

Add Driver Option

To add a single request option, use withOption().

$builder = $client
        ->withOption('delay', 800); 

Add Multiple Options

Use withOptions() to add multiple options at the same time. It accepts an array of key-value pairs.

$builder = $client
        ->withOptions([
            'delay' => 800,
            'force_ip_resolve' => 'v4',
            'sink' => '/responses/hotel-orders.log'
        ]); 

Remove Options

withoutOption() can be used to remove a single option. It accepts the request option's name, as it's argument.

$builder = $client
        ->withoutOption('delay'); 

Via Configuration

Lastly, as illustrated in previous sections, you may also specify request options via your configuration.

<?php

return [

    'profiles' => [

        'default' => [
            'driver' => \Aedart\Http\Clients\Drivers\DefaultHttpClient::class,
            'options' => [

                'delay' => 800,
                'force_ip_resolve' => 'v4',
                'sink' => '/responses/hotel-orders.log',
                'timeout' => 5,
                'read_timeout' => 10,
                'connect_timeout' => 2

                // ... remaining not shown ...
            ]
        ],
    ],
];