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

Declaration

<?php
Swoole\Coroutine\Http\Client->getHeaderOut(): string|bool

Parameters

None

Return

A string of plain-text headers or false if something went wrong.


Description

Get the HTTP request headers as plain text that were sent to the remote server.


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]);

    $client->setDefer(true);

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

    var_dump($client->getHeaderOut());

    $client->close();
});