Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
net/http: the comment of Server.IdleTimeout doesn't describe its behavior correctly #32053
What version of Go are you using (
@bradfitz the current documentation is slightly incorrect. The earlier comment was
The correct sequence is this. At the end of the current request, it sets deadline for IdleTimeout or ReadTimeout, whichever is non zero. At the beginning of the next request, it sets deadline for ReadHeaderTimeout or ReadTimeout, whichever is non zero. The missing piece in the documentation is the last part where ReadTimeout is considered yet again.
In case IdleTimeout and ReadHeaderTimeout are both zeros and ReadTimeout is non zero, it sets up two timeouts with ReadTimeout duration and if none of the former two are zeros, it would end up setting two timeouts - IdleTimeout & ReadHeaderTimeout.
I'm not sure if this was the intended behaviour. And assuming that the code is working as intended, I guess it is enough if we revert the IdleTimeout documentation to the previous version and add a line in the ReadHeaderTimeout to mention that it falls back to ReadTimeout in case the former is zero.
Please let me know if this sounds good; I will send a CL.