hijack method

  1. @override
Future<void> hijack(
  1. covariant IOAdapterRequest request,
  2. HijackCallback callback
)
override

Hijacks the connection associated with the AdapterRequest.

This passes control of the underlying communication channel (e.g., socket) to the provided callback. The callback receives a StreamChannel for direct, low-level interaction with the client.

This is typically used for protocols like SSE or to support custom streaming scenarios where the standard request-response model, or web-socket communication is insufficient.

For web-sockets see connect

Implementation

@override
Future<void> hijack(
  covariant final IOAdapterRequest request,
  final HijackCallback callback,
) async {
  final socket =
      await request._httpRequest.response.detachSocket(writeHeaders: false);
  callback(StreamChannel(socket, socket));
}