Some doubts about http.Server ConnContext

83 views
Skip to first unread message

Manlio Perillo

unread,
Jan 9, 2020, 9:36:34 AM1/9/20
to golang-nuts
I have some doubts about the usefulness of Server.ConnContext, given that it exposes the underlying network connection.

IMHO, the only things that can be obtained by net.Conn are the local address (already in LocalAddrContextKey) and the remote address and the TLS info (already in Request).
The only advantage of ConnContext is that it will be called before all the handlers.
Am I missing something?  https://github.com/golang/go/issues/30694 does not seem to list some useful usage.

On the other way, ConnContext can easily be abused:

The use case of the example is an handler that want to return an SSE response.
To avoid abuse, Server.WriteTimeout is not useful.  Instead a per write timeout is required, as it is done by Nginx https://nginx.org/en/docs/http/ngx_http_core_module.html#send_timeout.


Thanks
Manlio Perillo
Reply all
Reply to author
Forward
0 new messages