PHP Guzzle:空身反应
发布时间:2020-05-25 09:24:52 所属栏目:PHP 来源:互联网
导读:我刚刚开始尝试guzzle,但我在响应体上得到一个空字符串 $client = new Client([ base_uri = http://httpbin.org, timeout = 2.0, ]); $response = $client-request(GET, , [debug = true]); var_dum
|
我刚刚开始尝试guzzle,但我在响应体上得到一个空字符串 $client = new Client([
'base_uri' => 'http://httpbin.org','timeout' => 2.0,]);
$response = $client->request('GET','',['debug' => true]);
var_dump($response->getBody()->getContents());
我得到的回应是: * About to connect() to httpbin.org port 80 (#0) * Trying 23.22.14.18... * Connected to httpbin.org (23.22.14.18) port 80 (#0) > GET / HTTP/1.1 User-Agent: GuzzleHttp/6.2.0 curl/7.29.0 PHP/5.5.34 Host: httpbin.org HTTP/1.1 200 OK Server: nginx Date: Mon,06 Jun 2016 06:48:13 GMT Content-Type: text/html; charset=utf-8 Content-Length: 12150 Connection: keep-alive Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true * Connection #0 to host httpbin.org left intact string(0) "" 你可以看到正文是“”但内容长度是正确的. guzzlehttp / psr7的master分支上有一个错误的提交.如果你在composer.json文件中锁定版本,一切都应该按预期工作."guzzlehttp/guzzle": "6.2","guzzlehttp/psr7": "1.3" (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
