Home >Backend Development >PHP Tutorial >curl Expect:100-continue

curl Expect:100-continue

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-08-08 09:31:391376browse

curl Expect:100-continue

When using curl POST data, if the POST data is greater 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 from 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 this will appear one question. 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:"));

The above has introduced curl Expect:100-continue, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn