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.
Right now
httpc:set_keepalivewill 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
httpcto track whether the request and response has completed successfully (probably at the end of the body readers + a few more places) andset_keepalive()will only pool if the socket is ready.This will prevent pooling sockets in strange states.