Guzzle + openHAB REST API: "cURL error 61: Unrecognized content encoding type. libcurl understands d



我的openHAB系统的Guzzle和RESTneneneba API有一些问题。

我有一个全新的Laravel 7安装,在那里我使用Guzzle从openHAB API检索Things。这对于到/things端点的GET请求来说很好。然而,当我尝试向特定的Things端点/things/UUID发送请求时,我会收到以下错误:

GuzzleHttpExceptionRequestException 
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 GuzzleHttpClient([
'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获取内容似乎是一件微不足道的事情,所以我不明白为什么这两个系统之间会出现编码问题。

知道如何解决这个问题吗

这不是您的错,而是服务器的错。

您从服务器获得的Content-Encoding: UTF-8不正确。此标头应包含传输编码类型(如gzipdeflate(,但不应包含字符集(UTF-8(。

最好的选择是联系服务器的开发人员并在那里解决问题。在那之前,你什么都做不了。

最新更新