Document Introduction:The hyperlink login is visible.
When calling the other party's interface through curl, it was found that the timeout phenomenon was very serious, so I asked the other party's interface person, and the other party said that it was necessary to add:
After adding it, I found that it really worked well, so I researched how to use it. When using curl for POST, when "POST data is greater than 1024 bytes", curl will not directly initiate a POST request, but will be divided into 2 steps:
Expect: 100-continue
1. Send a request containing an Expect:100-continue, asking the server to accept the data
2. After receiving the 100-continue reply returned by the Server, the data is POSTed to the Server
But there are several problems with this:
Not all servers will correctly respond to 100-continue, e.g. lighttpd, which will return 417 Expectation Failed.
causing delay,When the client sends the first Expect:100-continue, it needs to wait for the server to answer before sending the request body。
If you are sure that the other party's server will not reject POST requests of more than 1024 bytes, you can avoid using this method and avoid the two side effects mentioned above, and the solution is the one mentioned at the beginning of the article.
About 100 continue
The purpose of this is to:
It allows the client to judge whether the server is willing to receive the request data before sending it, and if the server is willing to receive it, the client will actually send the data.
Client behavior:
A client that sends 100 continue should not wait forever for a response from the server, and after a period of timeout, the client should send the entity directly.
Server-side behavior:
If the server receives a 100 continue request, it will respond with 100 continue or send an error code. The server can never send 100 continue to a client that does not send 100 continue. But some servers do. IIS 5 incorrectly sending 100-continue response
If the server receives the client's body before sending the 100 continue response, it means that the client has decided to start sending data, so the server can no longer send 100 continue to the client. The .NET Expect Off Expect setting code is as follows:
RestSharp is set up as follows:
|