Apache1.1 POST request without body bug

Source: Internet
Author: User

Cause
Developers posted in the Forum said php sdk has a problem, and initial positioning, found the solution, but do not understand the reason, see: http://open.taobao.com/bbs/read.php? Tid = 18801

Solution Process
Because I can't reproduce the post in both the official environment and sandbox, leaving a message to allow developers to remotely assist trademanager.
At five o'clock P.M., trademanager contacted the developer for technical support. After one and a half hours of Remote Desktop debugging, he finally found the cause of the problem. The solution has been told to the developer that the SDK has been updated.

Technical Analysis
This is an HTTP Communication details. When PHP curl initiates a request to top, the http post method is set by default, but no post content is set. As a result, libcurl sends an HTTP request, include the following header:
Secondary CT: 100-continue
Content-Length:-1
When apache sees such a request, it throws a 302 error.

Wrong CT: 100-what does continue do?
Under normal circumstances, only when the post body exceeds 1024 bytes requires the HTTP client to send a request with a response CT: 100-continue. The web server returns a 100-continue response, the client resends the request.

Why is there Content-Length:-1?
Because the php sdk sets the POST method (curl_setopt ($ ch, curlopt_post, true);) but does not give it post content, the length is-1.

Why can't I reproduce it?
Because I am using PHP 5.2.12/libcurl 7.19.3, this curl version does not produce this error and is compatible with this error.
The developer uses php5.2.13/libcurl 7.20.0. This curl version supports strict HTTP protocol and is no longer compatible with HTTP protocol.
The problem caused by the environment is difficult to check, so the remote assistance took 90 minutes.

Conclusion
Based on the previous multipart issue, HTTP Communication is a relatively difficult technical point for most developers (whether Java or PHP), or it is easy to use the official SDK.

PS: the Java SDK does not have this problem.

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.