2 ms·
> Golang's HTTP server API does not provide any way to detect peer disconnect before sending the final response [3]. Iirc, the context mechanism can be used to
by ainar-g 6y ago
> Golang's HTTP server API does not provide any way to detect peer disconnect before sending the final response [3].
Iirc, the context mechanism can be used to detect
the client's disconnection or cancellation of the request
in some cases. From [1]:
> For incoming server requests, the context is canceled when the client's connection closes, the request is canceled (with HTTP/2), or when the ServeHTTP method returns.
[1]: https://golang.org/pkg/net/http/#Request.Context https://golang.org/pkg/net/http/#Request.Context
- mleonhard 6y agoGood. Thanks.