POST is an unsafe method as it’s not idempotent and does have side-effects. Therefore, POST operations are not safe to be re-tried.
Persistent connections and race conditions
HTTP connections are commonly used for multiple requests, that is, they are kept alive between requests.
A common scenario where this setting is useful is to prevent a race condition inherent in HTTP: in most cases, a server or reverse-proxy closes a persistent (kept-alive) connection after some time. However HTTP does not define a protocol between client and server to negotiate a graceful teardown of an idle persistent connection. Therefore, it can happen that a server decides to close a connection at the same time that a client decides to send a new request. In that case, the request will fail to be processed, but the client cannot determine for which reason the server closed the connection and whether the request was (partly) processed or not. Such a condition can be observed when a request fails with an
UnexpectedConnectionClosureException or a
StreamTcpException stating “Connection reset by peer”.