Thijs van Dien 9 Posted December 2, 2020 (edited) So far, I've been recreating my HTTP client (and SSL handler) for every request, because I'm a little paranoid of leftover state that could affect stability and/or correctness. The price I pay for that, is that I can't benefit from keep-alive. What would I have to do to make sure that no previous request has any influence on the (observable) state of TIdHTTP, except for keeping the connection open? Completely erasing the last response (how?) would be a good start, but perhaps there's more I can do to keep state to a minimum, and always start fresh to the extent possible, while being more efficient at the network level. Edited December 2, 2020 by Thijs van Dien Share this post Link to post
Der schöne Günther 316 Posted December 2, 2020 (edited) This doesn't answer your question, but ... ... this screams for unit tests like "Ensure requests are still properly going out after the previous server disconnected right in the middle of the transfer, sent garbage or timed out". Not only would you not have to constantly re-recreate clients, you can also sleep easier, knowing (instead of hoping) it works. Edited December 2, 2020 by Der schöne Günther Share this post Link to post
Remy Lebeau 1394 Posted December 2, 2020 14 hours ago, Thijs van Dien said: What would I have to do to make sure that no previous request has any influence on the (observable) state of TIdHTTP, except for keeping the connection open? TIdHTTP should already be handling that for you. You don't typically need to do anything extra when sending multiple requests over a single connection. 14 hours ago, Thijs van Dien said: Completely erasing the last response (how?) would be a good start Look at TIdHTTP.Request.Clear() and TIdHTTP.Response.Clear() 14 hours ago, Thijs van Dien said: but perhaps there's more I can do to keep state to a minimum, and always start fresh to the extent possible, while being more efficient at the network level. Have you actually TRIED to send multiple requests over a single connection and are running in a REAL PROBLEM with it? If so, what? Or, are you just SPECULATING? Share this post Link to post