I am experimenting with the
Expect:100-Continue Header and i am facing an 5 second delay between sending the http body to the server and receiving the 100 Continue response code from the server.
Here is the client code
I am not interested in parsing the http data sent from the client but only in responding to it. In this case i just print the data received . From the
RFC Docs i have learnt that this is a 2 step process
1. The client sends headers and the server is supposed to respond with an 100 Continue code if the server has no problems with them. In this case i skip all checking and directly send 100 Continue
2. After the client sends the request body the server is supposed to respond with an final status code [200 OK or any other] to indicate end of the body. I send 200 response code
Here is the server
The problem is that there is an 5 second delay between step 1 and 2. If i respond with any other status code besides 100 for example
Then on the client side an exception is thrown immediately saying server rejected the request which makes perfect sense but when I send the 100 response code the server receives the body after 5 seconds.
Here is the output on the server side
Here is the output on the client
The same thing happens when i use chunk Transfer mode as well . Between each chunk there is an 5 second delay
Here is the
Question from which i got the code from and modified it. The User has marked the answer as accepted but didn't give any code explanation as to how he solved the problem. If i were to ask the question there now it would get marked as duplicate.
How do i properly handle an Expect : 100 header in this case?