2016-08-10 44 views
1

需要壓縮(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'); 
    } 

回答

0

我想你也可以從similar question about pure cURL得到靈感。

嘗試使用與此狂飲自定義設置(我假設你正在使用它與捲曲處理):

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

$request = new Request($method, $uri, [], $requestBody); 
$response = $this->httpClient->send($request, $options);