This article mainly introduced the PHP use Curl appears expect:100-continue solution, the example analyzes the expect:100-continue appearance principle and the solution method, has certain reference value, the need friend may refer to under
The example in this article describes the Expect:100-continue solution for PHP using curl. Share to everyone for your reference. Specifically as follows:
When using curl post data, if the post has more than 1024 bytes of data, curl does not initiate a POST request directly. But there are two steps.
1. Send a request that contains a expect:100-continue in the header that asks the server if it is willing to accept the data.
2. Post the data to the server only after receiving the 100-continue response returned by the server.
This is Libcurl definition, you can see the relevant description: http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.3
So there is a problem. Not all servers will respond to 100-continue. For example, LIGHTTPD will return "417 expectation Fail", which can cause logical errors.
The workaround is to include an empty expect in the header when sending the request.
?
1 |
curl_setopt ($ch, Curlopt_httpheader, Array ("Expect:")); |
I hope this article will help you with your PHP program design.