About HTTP requests return 417 "expectation Failed"

Source: Internet
Author: User

when using HttpClient By default when you do the post, HttpClient The POST request will not be launched directly, but will be divided into two steps,

1. Send a request that contains a expect:100-continue that asks the server to use the data that is willing to accept

2. After receiving the 100-continue response returned by the server, post the data to the server

So, there is a problem, not all servers will correctly answer 100-continue, such as LIGHTTPD, will return 417 "expectation Failed", it will cause a logic error

The purpose of the Expect:100-continue handshake is to allow the client to determine whether the source server is willing to accept the request content before sending it
Request (based on the request header).
Expect:100-continue handshake needs to be used with caution because it can cause problems when encountering servers or proxies that do not support the http/1.1 protocol.
in HttpClient 4.0, if the expect:100-continue is activated, is controlled by the HTTP request execution parameter http.protocol.expect-continue, by setting the parameter value to TRUE or FALSE, the Expect:100-continue handshake can be activated or closed accordingly. Note that in HttpClient, the default is active.

Let's take a look at the description of this in the Http1.1 agreement.

(100 status code (see 10.) 1. Section 1) is intended to allow the client to determine whether the server is willing to accept the message body sent by the client (based on the request header domain) before the client sends this request message body. In some cases, if the server refuses to view the message body, it is inappropriate or inefficient for the client to send the message body. )

In fact, the key is the Http1.1 limit to shake hands first, we think about it, if we choose not to shake hands is not OK, of course, it is possible. The processing method is as follows

You can add this sentence directly before the HTTP request

false // no handshake direct Request

About HTTP requests return 417 "expectation Failed"

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.