Using Curl in PHP (a)

Source: Internet
Author: User

1, curl can only crawl part of the content of the page reason analysis:

Error hint: CURL transport Error:transfer closed with outstanding read data remaining

Libcurl enable the "Expect:100-continue" feature when sending more than 1024 bytes of data:

When using curl for post, when the data to post is greater than 1024 bytes, curl does not directly initiate the POST request, but is divided into two steps: 1. Sends a request that contains a "expect:100-continue" header field that asks if the Server is willing to receive data; 2. After receiving the 100-continue answer returned by the server, the data is POST to the server, which is the behavior of Libcurl.

First,Libcurl takes this approach when sending a POST request that is larger than 1024 bytes, but in contrast, it causes a greater request delay.

Second, not all Web servers can correctly handle and answer "100-continue", such as LIGHTTPD, and return 417 "expectation Failed", resulting in a request logic error. (Zheng note 1:LIGHTTPD version 1.4 has this serious problem, fixed in version 1.5.) Zheng Note 2:resin added support for expect:100-continue in version 3.0.5. )

Workaround: Modify the Curlopt entry:

Curlopt_httpheader = = Array ("Content-type:application/binary") is changed to Curlopt_httpheader = = Array (" Content-type:application/binary "," Expect: ")

Using Curl in PHP (a)

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.