RCA: Curl-library Post 1024 bytes is not noticed http/1.1 characteristics cause hessianphp _php Tutorial

Source: Internet
Author: User
Tags http post
The error message for hessianphp is listed first:

< span="">

Basic knowledge Background: 1) The ins and outs of "expect:100-continue":The purpose of the http/1.1 protocol is to design the Continue HTTP status code so that the http/1.1 protocol allows the client to determine whether the server is willing to accept the message body sent by the client before the client sends the request message (based on the request H eaders). That client and Server allow both parties to "shake hands" before Post (larger) data, and if the match is on, the client will start sending (larger) data。 The reason for this is that if the client sends the request data directly, but the server rejects the request, this behavior creates a significant resource overhead. The requirements of the protocol for http/1.1 clients are:
the < span=""> head field!
2) Enable the "Expect:100-continue" feature when sending more than 1024 bytes of data libcurl:

< span="">

< span=""> 1. Send a request that contains a "expect:100-continue" header field that asks if the server is willing toreceive data;2. After receiving the 100-continue response returned by the server, POST the data to S erver; < span="">

In 2012, ZXGFA added:

< span="">

< span=""> (Zheng < span=""> note 1:lighttpd 1.4 < span=""> Version has this serious problem fixed in version 1.5. Zheng Note 2:resin added support for expect:100-continue in version 3.0.5. )

3) PHP Curl-library can actively ban this feature:Someone in PHP Manual:: curl_setopt</strong> </strong> The message says: PHP Curl complies with Libcurl features. Because not all Web servers support this feature, a variety of errors are generated. If you encounter this, you can block the "Expect" header field with the following command: curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
?>
< span="">
Figure 1 You can convince PHP ' s curl backend to stop doing the 100-continue-thing by setting an explicit request header Other knowledge Background:
    • As described in the Hessiantransport code, the Hessian request using the CURL library.
problem Phenomenon:
, hessian error "CURL transport Error:transfer closed with outstanding read data remaining < span=""> ".
Solution:Modify Curlopt item in Hessian: Curlopt_httpheader = = Array ("Content-type:application/binary") to Curlopt_httpheader = Array ("Content-type:application/binary", "Expect:") P.S.: Some people think that the http/1.0 agreement can bypass this 100-continue problem, but it is only the engineer's reluctance to figure out the principle and show weakness. Reference resources: 1) 2011,laruence,expect:100-continue;2 php Manual, If doing a POST, and the content length is 1,025 or greater;3) HTT P 1.1 Rfc,use of the (Continue) status;4) stackoverflow,2009,php HTTP POST fails when CURL data > 1024;5) zxgfa,2012, Libcurl use Problem "expect100-continue"; 6) lighttpd,2009, ' Expect ' header gives HTTP error 417; A few pieces of gift: Please take the donor: 360 degree back kick: 360 No dead angle:

http://www.bkjia.com/PHPjc/440146.html www.bkjia.com true http://www.bkjia.com/PHPjc/440146.html techarticle first list the hessianphp error: basic knowledge Background: 1) expect:100-continue: http/1.1 protocol Design in the Continue HTTP status code of the purpose is, in the guest ...

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