简体   繁体   English

Guzzle + openHAB REST API:“cURL 错误 61:无法识别的内容编码类型。 libcurl 理解 deflate、gzip 内容编码”

[英]Guzzle + openHAB REST API: “cURL error 61: Unrecognized content encoding type. libcurl understands deflate, gzip content encodings ”

I have some problems with Guzzle and the REST API of my openHAB-system.我对 Guzzle 和我的 openHAB 系统的 REST API 有一些问题。

I have a fresh Laravel 7 installation, where I use Guzzle to retrieve Things from the openHAB API.我有一个全新的 Laravel 7 安装,我使用 Guzzle 从 openHAB API 中检索事物。 This works fine for a GET-request to the /things endpoint.这适用于对/things端点的 GET 请求。 However, when I try to send a request to a specific Things-endpoint /things/UUID I get the following error:但是,当我尝试向特定的 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)

I am not sure what this exactly means.我不确定这到底意味着什么。 Attached is a dump of the Guzzle Request Response in debug-mode:附件是调试模式下 Guzzle 请求响应的转储:

Instantiate Guzzle Client in PHP-code:在 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,
]);         

Debug-output from Guzzle Client: 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==

So far so good... Now comes the problem:到目前为止一切顺利......现在问题来了:

Guzzle Request that triggers the error:触发错误的 Guzzle 请求:

$response = $this->api()->request('GET', 'things/'.$uid);

Debug-output from Guzzle Request: 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

I am not sure what to do here?我不确定在这里做什么? It would seem like a trivial thing for Guzzle to fetch something from the openHAB API, so I do not understand why an encoding issue between these two systems would occur.对于 Guzzle 来说,从 openHAB API 中获取一些东西似乎是一件微不足道的事情,所以我不明白为什么这两个系统之间会出现编码问题。

Any idea how to resolve this problem?知道如何解决这个问题吗?

It's not your fault, but server's fault.这不是你的错,而是服务器的错。

Content-Encoding: UTF-8 that you get from the server is incorrect. Content-Encoding: UTF-8不正确。 This header should contain transfer encoding type (like gzip or deflate ) , but not charset (UTF-8).此 header 应包含传输编码类型(如gzipdeflate ,但不包含字符集 (UTF-8)。

The best option is to contact the server's developer and fix the issue there.最好的选择是联系服务器的开发人员并在那里解决问题。 Until that you cannot really do anything.在那之前,你真的什么都做不了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM