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
proposal: net/http: Expose underlying Conn in http.ResponseWriter? #13570
I'd rather not expose the conn. It leads to people being too clever and messing with the stream. CloseNotifier and Hijack are annoying enough to maintain.
I think this is a bizarre enough requirement (I've never head of anybody ever setting TOS based on the HTTP request) that it's not worth supporting directly. I think you can just write a net.Listener implementation that tracks the underlying TCP conn fds, returns a RemoteAddr() that net/http puts in stringified form in Request.RemoteAddr, then an http.Handler wrapper which unwraps that RemoteAddr string to find the TCP connection and resets RemoteAddr to its usual form.
It sounds kinda hacky, but so is the original problems, so it seems fitting.