Swoole\Coroutine\Http\Client->getDefer()

Declaration

<?php
Swoole\Coroutine\Http\Client->getDefer(): bool

Parameters

None

Return

Returns a bool of either true or false if the defer mode is enabled or not.


Description

Get the HTTP defer mode status. Check if defer mode is on or off. See setDefer().


Example

<?php
use Swoole\Coroutine\HTTP\Client;

Co\run(function()
{
    $client = new Client('127.0.0.1', 80);

    $client->setHeaders([
        'Host' => "localhost",
        "User-Agent" => 'Chrome/49.0.2587.3',
        'Accept' => 'text/html,application/xhtml+xml,application/xml',
        'Accept-Encoding' => 'gzip',
    ]);

    $client->set([ 'timeout' => 1]);

    // Other coroutines can execute while waiting for requests
    $client->setDefer(true);

    $client->get('/index.php');

    echo "Defer Mode Status: " . $cli->getDefer() . "\n";

    var_dump($client->body);

    $cli->close();
});