[][src]Function warp::filters::ws::ws2

pub fn ws2() -> impl Filter<Extract = (Ws2,), Error = Rejection> + Copy

Creates a Websocket Filter.

The yielded Ws2 is used to finish the websocket upgrade.

Note

This filter combines multiple filters internally, so you don't need them:

  • Method must be GET
  • Header connection must be upgrade
  • Header upgrade must be websocket
  • Header sec-websocket-version must be 13
  • Header sec-websocket-key must be set.

If the filters are met, yields a Ws2. Calling Ws2::on_upgrade will return a reply with:

  • Status of 101 Switching Protocols
  • Header connection: upgrade
  • Header upgrade: websocket
  • Header sec-websocket-accept with the hash value of the received key.