Thank you -- that makes sense. I was initially thrown off by the fact that
the connection remains open for netcat to get the full HTTP response.
For posterity, another way to get the desired behaviour is to invoke netcat
as follows, noting that it won't exit by itself anymore:
> cat ~/tmp/paylo
I assume netcat closes the connection once it gets an EOF from stdin. Thus
the server notices the client disconnecting and cancels the context, as
advertised.
Try running nc without piping the input in and typing it out on the console.
On Mon, Jan 15, 2018 at 5:07 PM, wrote:
> According to https
According to https://golang.org/pkg/net/http/#Request.Context:
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.
My expectation, then, is for the following code to block: