需要将压缩(gzip)主体发送到服务器
e.g。
protected function postOrPutData($method, $data, $type, $uri = null, array $options = [])
{
$requestBody = $this->serializer->serialize($data, 'json');
$request = new Request($method, $uri, [], $requestBody);
$response = $this->httpClient->send($request, $options);
return $this->serializer->deserialize((string) $response->getBody(), $type, 'json');
}
答案 0 :(得分:-1)
我认为你也可以从similar question about pure cURL获得灵感。
尝试在Guzzle中使用此自定义设置(我假设您正在使用cURL处理程序):
$options['curl'] = [CURLOPT_ENCODING => 'gzip'];
$request = new Request($method, $uri, [], $requestBody);
$response = $this->httpClient->send($request, $options);