void hijack(HijackCallback callback(Stream<List<int>> stream, StreamSink<List<int>> sink))

Takes control of the underlying request socket.

Synchronously, this throws a HijackException that indicates to the adapter that it shouldn't emit a response itself. Asynchronously, callback is called with a Stream> and StreamSink>, respectively, that provide access to the underlying request socket.

If the sink is closed, the stream will be closed as well. The stream and sink may be the same object, as in the case of a dart:io Socket object.

This may only be called when using a Shelf adapter that supports hijacking, such as the dart:io adapter. In addition, a given request may only be hijacked once. canHijack can be used to detect whether this request can be hijacked.

Source

void hijack(HijackCallback callback) {
  if (_onHijack == null) {
    throw new StateError("This request can't be hijacked.");
  }

  _onHijack.run(callback);
  throw const HijackException();
}