学无先后,达者为师

网站首页 PHP其他 正文

php CURL 服务器响应慢的问题

更新时间: 2020-02-20 PHP其他

CURL速度慢可能与Expect:100-Continue有关,可以修改下代码试验一下:

  1.   1. 发送一个请求, 包含一个Expect:100-continue, 询问Server使用愿意接受数据
  2.   2. 接收到Server返回的100-continue应答以后, 才把数据POST给Server
  3. function SendPic($photoVip){
    //post数据
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://www.test.com/savecurl.php");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    //post最大数据为1024,如果大于就要加下面这句话不然会报错"Expect: 100-continue"
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $photoVip);
    $res=curl_exec($ch);
    curl_close($ch);
    //exit;

    }


栏目分类
最近更新