Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
net/http: Requests with already canceled context are passed to Handlers #18449
Please answer these questions before submitting your issue. Thanks!
What did you do?
If possible, provide a recipe for reproducing the error.
Run this server: https://play.golang.org/p/s4dAekw0Tn — it listens 2 sockets and proxies requests from one address to another to ensure final endpoint receives requests via single connection.
This issue likely related to #18447
What did you expect to see?
What did you see instead?
Does this issue reproduce with the latest release (go1.7.4)?
It depends on whether #18447 is a regression from 1.7 or it's just a matter of documenting extra cancelation case in Request.Context() docs. If former, this bug is likely a duplicate, if latter, it's probably a separate issue — it seems that Handlers can receive Requests with already canceled context if multiple requests are sent via single http/1.1 keep-alive connection.
I'm able to reproduce this without httputil.ReverseProxy just using netcat against final endpoint (localhost:8081) as well.
Here's a better reproduction: https://play.golang.org/p/Y7MEdQY27J