douer9399 2017-12-05 10:39
浏览 143

慢PHP cURL - 发送小base64_encode图像

I'm a posting a cURL request, but somehow it is not that fast. It takes about 6 seconds to finish. Within the cURL, I am sending a base64_encoded small image. 64x64px.


It might not be the image which slows the cURL, but something else. Here is the setup:

$url = 'the_URL';    
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
$json_response = curl_exec($curl);

This is the result:

Array ( 
[url] => the_URL?
[content_type] => application/json 
[http_code] => 200 
[header_size] => 441 
[request_size] => 165 
[filetime] => -1 
[ssl_verify_result] => 0 
[redirect_count] => 0 
[total_time] => 5.665052 
[namelookup_time] => 2.2E-5 
[connect_time] => 0.027501 
[pretransfer_time] => 0.091433 
[size_upload] => 204303 
[size_download] => 1149 
[speed_download] => 202 
[speed_upload] => 36063 
[download_content_length] => 1149 
[upload_content_length] => 204303 
[starttransfer_time] => 0.120824 
[redirect_time] => 0 
[redirect_url] => 
[primary_ip] => IP 
[certinfo] => Array ( ) 
)

I think 6 seconds is two slow for a cURL like this.

Do I miss something in my setup?

UPDATE!

No sorry. The file is in a zip, and the zip is base64_encoded. My bad. Today it took like 19 seconds to do the cURL execute.

Unfortunately the function curl_setopt($curl , CURLOPT_IPRESOLVE , CURL_IPRESOLVE_V4); didn't help at all.

There are two images in the zip. They are both 25kb... So it might not be the thing.

Any other suggestions?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
    • ¥15 不小心不正规的开发公司导致不给我们y码,
    • ¥15 我的代码无法在vc++中运行呀,错误很多
    • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
    • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
    • ¥30 ppOCRLabel导出识别结果失败
    • ¥15 Centos7 / PETGEM
    • ¥15 csmar数据进行spss描述性统计分析
    • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
    • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题