changeStream

fun changeStream(newStream: InputStream)

Swaps the underlying stream, discarding whatever is still buffered from the old one.

Discarding is the point: this is how the TLS upgrade takes over a connection, and bytes read before the handshake belong to the plaintext stream that no longer exists.