Hijack class final

A Result indicating that the underlying connection has been hijacked.

When a connection is hijacked, the handler takes full control of the underlying socket connection, bypassing the normal HTTP response cycle. This is useful for implementing custom protocols or handling raw socket communication.

Hijack customProtocolHandler(Request req) {
  return Hijack((channel) {
    log('Connection hijacked for custom protocol');

    // Send a custom HTTP response manually
    const response = 'HTTP/1.1 200 OK\r\n'
        'Content-Type: text/plain\r\n'
        'Connection: close\r\n'
        '\r\n'
        'Custom protocol response from Relic!';

    channel.sink.add(utf8.encode(response));
    channel.sink.close();
  });
}
Inheritance

Constructors

Hijack(HijackCallback callback)

Properties

callback HijackCallback
The callback function provided to handle the hijacked connection.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited