PHP using Curl appears expect:100-continue workaround _php Tutorial

Source: Internet
Author: User

PHP uses curl to appear expect:100-continue solution


This article mainly introduces PHP using curl appeared expect:100-continue solution, the example analyzes the expect:100-continue appearance principle and the solution method, has the certain reference value, needs the friend to refer to under

The examples in this article describe the Expect:100-continue workaround for PHP using curl. Share to everyone for your reference. Specific as follows:

When using the Curl post data, if the post data is greater than 1024 bytes, curl does not directly initiate the POST request. But it will be in two steps.

1. Send a request with a expect:100-continue in the header that asks if the server is willing to accept the data.
2. After accepting the 100-continue response returned by the server, the data is not post to the server.

This is libcurl defined, can be seen in 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 returns "417 expectation Fail", which can cause a logic error.

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 is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/964001.html www.bkjia.com true http://www.bkjia.com/PHPjc/964001.html techarticle PHP uses Curl to appear expect:100-continue solution This article mainly introduces PHP using Curl to appear expect:100-continue solution, the example analyzes expect:100- The principle and solution of continue ...

  • 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.