最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php curl常見錯誤:SSL錯誤、bool(false)

 更新時間:2011年12月28日 21:42:00   作者:  
在命令行中使用curl調用跳過SSL證書檢查的方法,需要的朋友可以參考下。
癥狀:php curl調用https出錯
排查方法:在命令行中使用curl調用試試。
原因:服務器所在機房無法驗證SSL證書。
解決辦法:跳過SSL證書檢查。
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

癥狀:php curl調用curl_exec返回bool(false),命令行curl調用正常。
排查方法:
var_dump(curl_error($ch));
返回:
string(23) "Empty reply from server"
再排查:
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
返回:
HTTP/1.1 100 Continue
Connection: close
原因:php curl接收到HTTP 100就結束了,應該繼續(xù)接收HTTP 200
解決方案:
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));

PHP and cURL: Disabling 100-continue header
Published June 15th, 2006
I've been using cURL (through PHP) to build a sort of proxy for a project I'm working on. I need to parse the returned headers (to recover the HTTP status), so had included a very simple script to do so. It had worked fine in the past, but for some reason barfed in this case. A closer look at what was being returned revealed that for some reason, Apache was prepending the ‘normal' headers with an extra response header:

HTTP/1.1 100 Continue

HTTP/1.1 200 OK Date: Fri, 09 Jun 2006 15:23:42 GMT
Server: Apache
...A bit of Googling revealed that this was to do with a header that cURL sends by default:

Expect: 100-continue

…which in turns tells Apache to send the extra header. I poked around a fair bit but couldn't quite find a workable solution short of manually removing the header in PHP, which seemed a bit clumsy. Finally, on a hunch I tried this:

curl_setopt( $curl_handle, CURLOPT_HTTPHEADER, array( 'Expect:' ) );

…which basically overrides the original ‘Expect:' header with an empty one.

Hope this helps someone.

相關文章

最新評論

玉门市| 大石桥市| 保靖县| 汪清县| 襄樊市| 织金县| 红桥区| 民丰县| 织金县| 吴江市| 普兰县| 三原县| 丰城市| 乌鲁木齐市| 堆龙德庆县| 黄平县| 临海市| 澜沧| 五指山市| 家居| 富锦市| 玛沁县| 大名县| 星子县| 灵丘县| 汝城县| 桃园县| 龙里县| 恩施市| 酒泉市| 长沙市| 巩留县| 盐边县| 柳州市| 高要市| 荔浦县| 四平市| 湖州市| 齐齐哈尔市| 读书| 和顺县|