Repository navigation
Tell the client the connection is closing after each response - #212
arpitjain099 wants to merge 1 commit into
Conversation
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
|
Thanks for tracking this down; the diagnosis in #211 and the RFC 9112 reasoning both look right to me for the transparent paths. One concern: I checked this with a throwaway test: 5 sequential HTTPS requests through the explicit proxy with one Go client, counting new connections with The existing A suggestion that keeps the fix and avoids the regression: let the caller say whether the connection closes after this response, since only the caller knows. For example, add a
Removing the upstream This also affects #216, which makes A test case that would catch this: establish a tunnel with Happy to help with that change or the test if useful. |
Fixes #211.
handleHTTPConnectionandhandleTLSConnectioneach read one request and close the connection in a defer, but neither response says so. The upstreamConnection: keep-aliveis not passed through either, so a client that pools sockets, Node'shttps.Agent({keepAlive: true})in the report, keeps the socket and the next write lands on a connection the proxy has already gone away from. That is the alternatingsocket hang upin the issue, and it is whycode-server --install-extensionfails outright andnpm installcrawls.RFC 9112 section 9.6 puts that on the sender: if you are going to close, say so. The forwarded response now drops any upstream
Connectionheader and setsresp.Close, soResponse.WriteemitsConnection: close, and the blocked 403 does the same.This is the first of the two options in the issue. Actually keeping connections alive, the second option, is the better outcome for throughput, but it means holding the connection open and looping over requests in both handlers, which is a larger change and a design call for you rather than something to slip into a bug fix.
The test starts a local backend, goes through the proxy for one allowed and one blocked request, and asserts
resp.Closeon both. It fails on main with "response must tell the client the connection is closing".go test -race ./proxy/passes.