This article mainly introduces the solution to Expect:100-continue when using curl in php. An example analysis of Expect:100 -The principles and solutions of continue have certain reference value. Friends in need can refer to it
The example in this article describes the solution to Expect:100-continue when using curl in PHP. Share it with everyone for your reference. The details are as follows:
When using curl POST data, if the POST data is larger than 1024 bytes, curl will not directly initiate a POST request. Instead, it will be done in two steps.
1. Send a request with an Expect:100-continue in the header to ask the server if it is willing to accept data.
2. After receiving the 100-continue response returned by the server, POST the data to the server.
This is defined by libcurl. For details, you can view the relevant description: http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.3
So a problem will arise. Not all servers will respond with 100-continue. For example, lighttpd will return "417 Expectation Fail", which will cause logical errors.
The solution is as follows: when sending a request, the header contains an empty Expect.
?
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Expect:"));
|
I hope this article will be helpful to everyone’s PHP programming design.
TechArticle