cpprestsdk
cpprestsdk copied to clipboard
Try to resend request if connection has been closed.
Hi, all!
Case: We've got a client that sends messages to a server. I came across a problem when client failed to write request body. I found out that the reason was the connection was closed after the "keep-alive" timeout expired. They use HTTP/1.1 and Keep-Alive connection.
Tcpdump trace:

155 - client, 159 - server. At the beginning, the client sends a request and accepts a response from the server. Then, in 19 secs FIN packet is arrived. At 209.852367 we try to write headers. In response, we accepts RST packet. In cpprestsdk it means "Broken pipe" at https://github.com/microsoft/cpprestsdk/blob/master/Release/src/http/client/http_client_asio.cpp#L1303.
My solution: There is an attempt to restore the closed connection at https://github.com/microsoft/cpprestsdk/blob/master/Release/src/http/client/http_client_asio.cpp#L1347. I decided to use this method to handle body write error. I managed to reproduce the error in unit-tests.
@barcharcraz, Could you review please?