我对 Guzzle 和我的 openHAB 系统的 REST API 有一些问题。
我有一个全新的 Laravel 7 安装,我使用 Guzzle 从 openHAB API 检索事物。/things
这适用于对端点的 GET 请求。但是,当我尝试向特定的 Things-endpoint 发送请求时,/things/UUID
我收到以下错误:
GuzzleHttp\Exception\RequestException
cURL error 61: Unrecognized content encoding type. libcurl understands deflate, gzip content encodings. (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)
我不确定这到底意味着什么。附件是调试模式下 Guzzle 请求响应的转储:
在 PHP 代码中实例化 Guzzle 客户端:
$this->guzzle_client = new \GuzzleHttp\Client([
'base_uri' => $protocol.$this->server_hostname.':'.$this->server_port.'/rest/',
'verify' => false,
'auth' => [$this->server_username, $this->server_password],
'debug' => true,
]);
Guzzle 客户端的调试输出:
* Trying 10.0.0.63...
* TCP_NODELAY set
* Connected to 10.0.0.63 (10.0.0.63) port 8080 (#0)
> GET /rest/things HTTP/1.1
Host: 10.0.0.63:8080
User-Agent: GuzzleHttp/6.5.5 curl/7.64.1 PHP/7.3.11
Authorization: Basic Og==
到目前为止一切顺利......现在问题来了:
触发错误的 Guzzle 请求:
$response = $this->api()->request('GET', 'things/'.$uid);
Guzzle 请求的调试输出:
* Found bundle for host 10.0.0.63: 0x7fafc9d7acb0 [can pipeline]
* Re-using existing connection! (#0) with host 10.0.0.63
* Connected to 10.0.0.63 (10.0.0.63) port 8080 (#0)
> GET /rest/things/zwave%3Adevice%3A23daaff0%3Anode7 HTTP/1.1
Host: 10.0.0.63:8080
User-Agent: GuzzleHttp/6.5.5 curl/7.64.1 PHP/7.3.11
Authorization: Basic Og==
< HTTP/1.1 200 OK
< Content-Type: application/json
< Content-Encoding: UTF-8
< Content-Length: 7386
< Server: Jetty(9.4.20.v20190813)
<
* Unrecognized content encoding type. libcurl understands deflate, gzip content encodings.
* Closing connection 0
我不确定在这里做什么?对于 Guzzle 来说,从 openHAB API 获取某些东西似乎是一件微不足道的事情,所以我不明白为什么这两个系统之间会出现编码问题。
知道如何解决这个问题吗?