如何压缩(gzip的)在狂饮的请求6

需要压缩(gzip的)主体发送到服务器如何压缩(gzip的)在狂饮的请求6

例如体

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');

}

回答:

我想你也可以从similar question about pure cURL得到灵感。

尝试使用与此狂饮自定义设置(我假设你正在使用它与卷曲处理):

$options['curl'] = [CURLOPT_ENCODING => 'gzip']; 

$request = new Request($method, $uri, [], $requestBody);

$response = $this->httpClient->send($request, $options);

以上是 如何压缩(gzip的)在狂饮的请求6 的全部内容, 来源链接: utcz.com/qa/266893.html

回到顶部