lua-resty-http icon indicating copy to clipboard operation
lua-resty-http copied to clipboard

Harden set_keepalive() to pool only when response read

Open GuyLewin opened this issue 3 years ago • 0 comments

Right now httpc:set_keepalive will pool any socket if the HTTP response version + Connection response header support it, even if the body wasn't read yet and the socket isn't ready to be pooled (assuming the body wasn't received by OpenResty yet, because then it will return an error). I suggest we keep an internal state in httpc to track whether the request and response has completed successfully (probably at the end of the body readers + a few more places) and set_keepalive() will only pool if the socket is ready. This will prevent pooling sockets in strange states.

GuyLewin avatar Sep 21 '21 01:09 GuyLewin