PHP uses curl to appear expect:100-continue solution

Source: Internet
Author: User
Tags curl

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.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.