dte66654 2018-05-24 18:50
浏览 48

请求仅压缩数据

im trying to make a request in a remote xml file, and i receive a response from the server saying:

"Access denied, only compressed data can be send"

So i try using in my request:

$guzzleClient = new Client();
$feed_response = $guzzleClient->request('GET', $url,[
    'headers' => [
        'Accept-encoding: gzip'
    ],

    'debug' => true
]);
echo $feed_response->getStatusCode();

But it doesnt work, it gives me the same error, but if i use a example using curl:

curl -sH 'Accept-encoding: gzip' "domain/xmlfile" --compressed

It works fine, can someone tell me what is missing on the guzzle options?

  • 写回答

1条回答 默认 最新

  • douzhan6474 2018-05-25 10:59
    关注

    The solution was:

    $feed_response = $guzzleClient->request('GET', $url,[
    
                        'headers'        => ['Accept-Encoding' => 'deflate, gzip'],
    
    
                   // 'debug' => true
                ]);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败