Websocket: FollowRedirect middleware
July 22, 2024 ยท View on GitHub
Documentation / Middleware / FollowRedirect
Websocket: FollowRedirect middleware
This middlewares is included in library and can be added to provide additional functionality.
Can only be added to Client.
During handshake, it reacts to 3xx HTTP status and reconnect the Client to provided location.
Client
Will follow redirect by setting new URI and reconnect the Client if;
- Server response during handshake has a
3xxstatus - Server response also includes a
Locationheader - Maximum number of redirects has not been exceeded
$client->addMiddleware(new WebSocket\Middleware\FollowRedirect());
$client->connect();
Maximum number of redirects
By default, maximum number of redirects in 10.
If middleware receive additional redirect instructions after that, it will throw a HandshakeException.
It is also possible to specify maximum number of redirects as parameter.
// Allow 20 redirects
$client->addMiddleware(new WebSocket\Middleware\FollowRedirect(20);