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"