doubaran2438 2017-01-03 05:59
浏览 217

PHP cURL加载时间太长

I have issue with cURL request from live server. I already seen this url but not getting that solution.

Try to request local URL than its takes 562ms.

But the same code take 1.1 min from live URL.

below are the curl_getinfo($cSession) details :

Array
(
    [url] => http://***.***.**.**
    [content_type] => 
    [http_code] => 0
    [header_size] => 0
    [request_size] => 0
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 62.261039
    [namelookup_time] => 0.000148
    [connect_time] => 0
    [pretransfer_time] => 0
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => -1
    [upload_content_length] => -1
    [starttransfer_time] => 0
    [redirect_time] => 0
    [certinfo] => Array
        (
        )

    [primary_ip] => 
    [primary_port] => 0
    [local_ip] => 
    [local_port] => 0
    [redirect_url] => 
)

below I'm using code :

$cSession = curl_init();
//step2

curl_setopt($cSession, CURLOPT_URL,"$url");
curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($cSession, CURLOPT_HEADER, false);
curl_setopt($cSession, CURLOPT_ENCODING, 'gzip');

//step3
$result=curl_exec($cSession);
$cinfo = curl_getinfo($cSession);

//step4
curl_close($cSession);

//step5, result of curl
// echo $result;

print_r($cinfo);

Can anyone please help me, where I'm failed.

  • 写回答

1条回答 默认 最新

  • dtmwnqng38644 2017-03-13 10:17
    关注

    Instead of

    curl_setopt($cSession, CURLOPT_ENCODING, 'gzip');
    

    Try to use

    curl_setopt($cSession, CURLOPT_ENCODING, '');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退