1

需要将压缩(gzip)正文发送到服务器

例如

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

1 回答 1

-1

我认为您也可以从有关纯 cURL 的类似问题中获得灵感。

尝试将此自定义设置与 Guzzle 一起使用(我假设您将其与 cURL 处理程序一起使用):

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

$request  = new Request($method, $uri, [], $requestBody);
$response = $this->httpClient->send($request, $options);
于 2016-08-10T19:04:50.600 回答