PHP Curl Common errors: SSL error, BOOL (false) _php tips

Source: Internet
Author: User
Tags http 200 ssl certificate
Symptom (s): Php Curl Call HTTPS error
Troubleshooting methods: Try using the curl call at the command line.
Reason: The server room cannot authenticate the SSL certificate.
Workaround: Skip SSL certificate checking.
curl_setopt ($ch, Curlopt_ssl_verifypeer, false);

Symptom (s): the PHP Curl call Curl_exec returns BOOL (false), and the command line curl calls normally.
Troubleshooting methods:
Var_dump (Curl_error ($ch));
Return:
String (Empty reply from server)
Further investigation:
curl_setopt ($ch, Curlopt_header, true);
curl_setopt ($ch, Curlopt_returntransfer, false);
return:
http/1.1 Continue
Connection:close
Reason: Php Curl received HTTP 100 is over, should continue to receive HTTP 200
Solution:
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 in project I ' m working on. I need to parse the returned headers (to recover the HTTP status), so had included a very simple script. The It had worked fine in the past, but for some reason to this case. A closer look at what is being returned revealed this for some reason, Apache is prepending the ' normal ' headers with an Extra response Header:

http/1.1 Continue

http/1.1 OK Date:fri, June 2006 15:23:42 GMT
Server:apache
... A bit of Googling revealed that this is to does 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.