• 响应

    响应

    1. <?php
    2. include "./vendor/autoload.php";
    3. \EasySwoole\EasySwoole\Core::getInstance()->initialize();
    4. go(function () {
    5. $client = new \EasySwoole\HttpClient\HttpClient();
    6. $client->setUrl('http://a.cn');//设置url,注意需要http和https,https
    7. $client->addCookie('a','1');
    8. $response = $client->exec();
    9. var_dump($response->getBody());//获取响应主体
    10. var_dump($response->getErrCode());//获取错误码
    11. var_dump($response->getErrMsg());//获取错误信息
    12. var_dump($response->getStatusCode());//获取响应状态码
    13. var_dump($response->getCookiesRaw());//获取响应头想要设置的cookie
    14. var_dump($response->getCookies());//获取自己发送的cookie,以及响应头想要设置的cookie
    15. });