gpt4 book ai didi

PHP Guzzle : Empty body response

转载 作者:可可西里 更新时间:2023-11-01 13:19:06 27 4
gpt4 key购买 nike

我刚开始尝试使用 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) ""

如您所见,正文为“”,但 Content-Length 是正确的。

最佳答案

guzzlehttp/psr7 的 master 分支上有错误提交。如果您在 composer.json 文件中锁定版本,一切都应该按预期工作。

"guzzlehttp/guzzle": "6.2",
"guzzlehttp/psr7": "1.3"

关于PHP Guzzle : Empty body response,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37651164/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com