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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
    • ¥15 如何处理复杂数据表格的除法运算
    • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
    • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
    • ¥200 uniapp长期运行卡死问题解决
    • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
    • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
    • ¥15 乘性高斯噪声在深度学习网络中的应用
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集