doulu6234 2010-07-17 16:24
浏览 46
已采纳

Zend_Http_Client无法解码回复?

I am trying to use Zend_Http_Client to fetch a specific page (www . nu . nl) I am using this code

$client = new Zend_Http_Client($url,
    array(
        'maxredirects' => 5, 
        'timeout' => 30,
        'useragent' => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.3) Gecko/20010801 '
    )
);
$code = $client->request("GET");
$pageBody = $code->getBody();

For this specific site, $pagebody is empty (0). Using xdebug, it seems that it fetches the encoded response but fails on the decoding. Also, and this is wierd to me, sometimes it works with no problem!

I would appreciate any thoughts on how to solve this.

Thank you.

  • 写回答

1条回答 默认 最新

  • duanchong3075 2010-07-19 18:50
    关注

    Sorry but I am not able to reproduce your problem.

    $url = 'http://www.nu.nl';
    $client = new Zend_Http_Client($url, array(
        'maxredirects' => 5,
        'timeout' => 30,
        'useragent' => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.3) Gecko/20010801 '
    ));
    
    $response = $client->request("GET");
    $pageBody = $response->getBody();
    var_dump(strlen($pageBody));
    

    Output: int(36902)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 vscode的问题提问
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM