'Take control of the underlying stream.
Returns the underlying `.IOStream` object and stops all further
HTTP processing.  May only be called during
`.HTTPMessageDelegate.headers_received`.  Intended for implementing
protocols like websockets that tunnel over an HTTP handshake.'

def detach(self):

    self._clear_callbacks()
    stream = self.stream
    self.stream = None
    if (not self._finish_future.done()):
        self._finish_future.set_result(None)
    return stream
