Net.HTTP.Duplex
A connection after it switched protocols: what the peer sends next, and
what this side writes back, in the protocol both agreed to. A server's
switch and a client's upgrade both hand one over.
A Duplex is a Net.Connection: shutdownWrite ends this side's output
and the peer can go on sending, setDeadline bounds the reads and writes
that follow, and close closes the connection under it. It never hands
out that connection itself, which the library closes once the function it
was given to returns. Bytes the peer sent after the head, before the
switch, are read first.
The connection is reached through closures, so that one type serves TCP, TLS and the in-memory connections tests use, and a function written once runs over any of them.
Returns a duplex over the operations given: a read into a buffer, a write and a flush, a deadline set or cleared, a half-close and a close. For the server and the client that switch a connection.