Description
The existing implementation makes it impossible to run a Server with keep-alive that both gets notified about disconnecting clients and is capable of handling upgrade requests (such as to websocket protocol).
For example, consider the recent change to utilize CloseNotifier within the httputil.ReverseProxy: ececbe8
That's an important change for a reverse proxy because it allows upstream servers to stop doing work for clients that have gone away. Without that behavior, servers are much more vulnerable to resource exhaustion by misbehaving clients that disconnect immediately after making a request.
However, suppose that a Server not only wanted to defend against disconnecting clients, but also wanted to be able to handle HTTP Upgrade (or websocket) requests. That can only be implemented in http.Server by using the ResponseWriter's Hijacker interface to hijack the underlying net.Conn.
However, those two features are explicitly blocked from being used together. There's a good underlying reason for that: once CloseNotify() is called, there's an io.Copy reading from the underlying net.Conn that cannot be cleanly interrupted.
I think it's important to be able to use both of these features together in the same Server. One could imagine adding websocket or more general HTTP Upgrade support to the ReverseProxy, or simply supporting such features from a Server that also wants to know when clients go away on normal requests.
What version of Go are you using (go version)?
go1.4.1
What operating system and processor architecture are you using?
Darwin amd64
What did you do?
I attempted to Hijack()
on a re-used server connection, one that had been setup for CloseNotify()
on a previous request.
What did you expect to see?
I expected to be able to hijack the connection, even though in a previous request I had asked to be notified about disconnecting clients.
What did you see instead?
http: Hijack is incompatible with use of CloseNotifier