On Wed, Aug 2, 2017 at 5:55 AM, Konstantin Khomoutov <kos...@bswap.ru> wrote: > > The "conn" type from net/http/server.go, in its serve() method contains > a "for" loop which is supposed -- as I understand it -- to keep reading > requests from the connected socket if the client wished to reuse the > connection. > > That loop reads the request's header and then starts a background > goroutine which tries to read a single byte from the underlying > connection and does other cryptic stuff. > > After that, the user-installed request handler is run to process the request. > > I fail to comprehend what's the purpose of starting that background > goroutine. Can anyone please shed some light on what is that "trick" > really accomplishes. IOW, what would be wrong with simply attempting to > read from the client's connection after the handler has finished with > the current request?
I believe it's to support the Hijack method, which is used by net/rpc to implement an HTTP server that handles RPC requests. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.