症状: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就结束了,应该继续接收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.

php curl常见错误:SSL错误、bool(false)的更多相关文章

  1. Windows Server 2008R2常见的500错误

    每次公司服务器装系统后再去部署服务,都会碰到这个问题,这里记录一下问题的解决方法 遇到“500 – 内部服务器错误. 您查找的资源存在问题,因而无法显示.”的问题. 解决办法: 1.解决方法:打开II ...

  2. 常见的java 错误--转

    Java常见错误列表: 找不到符号(symbol) 类X是public的,应该被声明在名为X.java的文件中 缺失类.接口或枚举类型 缺失X 缺失标识符 非法的表达式开头 类型不兼容 非法的方法声明 ...

  3. git clone出现SSL错误

    在学习git的时候,发现不能使用git clone从github.com下载,报了个ssl错误. Cloning into cancan... error: SSL certificate probl ...

  4. python常见的编程错误

    常见的编程错误 2.1 试图访问一个未赋值的变量,会产生运行时错误. 2.2 ==,!=, >=和<=这几个运算符的两个符号之间出现空格,会造成语法错误. 2.3 !=,<>, ...

  5. 常见http代码错误原因及处理

    常见的HTTP错误可以分为以下四大类.每一大类又细分为很多类小错误.当您打不开网站或者打开网站报错时首先检查您输入的网站是否有误,检查网络是否有问题或者虚拟主机的DNS是否可以解析.确定没有问题时再看 ...

  6. 总结Selenium自动化测试方法(六)常见的异常错误处理

    六.常见的异常错误处理 NoSuchElementException: Message: Unable to locate element: {"method":"xpa ...

  7. 最常见的HTTP错误

    1. HTTP 500错误(内部服务器错误)对对HTTP 500错误的定义已经充分证明了这是一个最常见的HTTP错误. 一般来说,HTTP 500 错误就是web服务器发生内部错误时返回的信息. 例如 ...

  8. 大数据揭示的10个常见JAVA编程错误

    初学者最常犯的编程错误是什么呢?有可能他们总是混淆等值(==)与赋值(=),或者 & 和 &&:也有可能是他们在循环中使用错误的分隔符(for (int i = 0, i &l ...

  9. Android ROM开发(二)——ROM架构以及Updater-Script脚本分析,常见的Status错误解决办法

    Android ROM开发(二)--ROM架构以及Updater-Script脚本分析,常见的Status错误解决办法 怪自己二了,写好的不小心弄没了,现在只好重新写一些了,上篇简单的配置了一下环境, ...

随机推荐

  1. MTK 永不熄屏

    步骤一: 源码/frameworks/base/packages/SettingsProvider/res/values/defaults.xml 修改<integername=</int ...

  2. python--面向对象--14

    原创博文,转载请标明出处--周学伟http://www.cnblogs.com/zxouxuewei/ Python 面向对象 Python从设计之初就已经是一门面向对象的语言,正因为如此,在Pyth ...

  3. 从Gallery中获取图片示例

    一.MainActivity类 package com.example.gallerydemo; import android.net.Uri; import android.os.Bundle; i ...

  4. 使用pull方式解析xml文件示例:

    网上的示例太多,基本类似,个人在此做个简单的总结: 1.首先在工程的asserts目录下建一个book.xml文件: <?xml version="1.0" encoding ...

  5. PHP代码审计笔记--变量覆盖漏洞

    变量覆盖指的是用我们自定义的参数值替换程序原有的变量值,一般变量覆盖漏洞需要结合程序的其它功能来实现完整的攻击. 经常导致变量覆盖漏洞场景有:$$,extract()函数,parse_str()函数, ...

  6. SpringBoot(十)-- 整合MyBatis

    1.pom.xml 配置maven依赖 <dependency> <groupId>org.mybatis.spring.boot</groupId> <ar ...

  7. 2018.8.23几日重新编译OSG+OE+Qt遇到的问题

    Qt安装多个版本的时候,注意屏蔽掉不使用的Qt,例如OE中的CMakeLists.txt中的# FIND_PACKAGE(Qt4) 使用以前编译好的libcurl.dll现在出现"无法定位序 ...

  8. commons-beanutils的使用

    commons-beanutils是通过内省来完成的. 需要两个包: commons-beanutils-1.8.3.jar commons-logging-1.1.1.jar JavaBean类: ...

  9. PHP behavior 机制简单实现

    <?php class Base{ private $_m = array(); public function attachBehavior($behaviorObj){ $behaviorO ...

  10. [转载]WebConfig配置文件详解

    <?xml version="1.0"?> <!--注意: 除了手动编辑此文件以外,您还可以使用 Web 管理工具来配置应用程序的设置.可以使用 Visual S ...