pub fn ws2() -> impl Filter<Extract=One<Ws2>, Error=Rejection> + Copy {
    let connection_has_upgrade = header::header2()
        .and_then(|conn: ::headers::Connection| {
            if conn.contains("upgrade") {
                Ok(())
            } else {
                Err(::reject::bad_request())
            }
        })
        .unit();

    ::get2()
        .and(connection_has_upgrade)
        .and(header::exact_ignore_case("upgrade", "websocket"))
        .and(header::exact("sec-websocket-version", "13"))
        //.and(header::exact2(Upgrade::websocket()))
        //.and(header::exact2(SecWebsocketVersion::V13))
        .and(header::header2::<SecWebsocketKey>())
        .and(body::body())
        .map(move |key: SecWebsocketKey, body: ::hyper::Body| {
            Ws2 {
                body,
                key,
            }
        })
}
/// 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.
Creates a Websocket Filter.
The yielded `Ws2` is used to finish the websocket upgrade.
Creates a Websocket Filter . The yielded ` Ws2 ` is used to finish the websocket upgrade .
pub fn ws2() -> impl Filter<Extract=One<Ws2>, Error=Rejection> + Copy {
    let connection_has_upgrade = header::header2()
        .and_then(|conn: ::headers::Connection| {
            if conn.contains("upgrade") {
                Ok(())
            } else {
                Err(::reject::bad_request())
            }
        })
        .unit();
    ::get2()
        .and(connection_has_upgrade)
        .and(header::exact_ignore_case("upgrade", "websocket"))
        .and(header::exact("sec-websocket-version", "13"))
        //.and(header::exact2(Upgrade::websocket()))
        //.and(header::exact2(SecWebsocketVersion::V13))
        .and(header::header2::<SecWebsocketKey>())
        .and(body::body())
        .map(move |key: SecWebsocketKey, body: ::hyper::Body| {
            Ws2 {
                body,
                key,
            }
        })
}
pub fn ws2 ( ) -> impl Filter < Extract = One < Ws2 > , Error = Rejection > + Copy { let connection_has_upgrade = header :: header2 ( ) . and_then ( | conn : :: headers :: Connection | { if conn . contains ( " " ) { Ok ( ( ) ) } else { Err ( :: reject :: bad_request ( ) ) } } ) . unit ( ) ; :: get2 ( ) . and ( connection_has_upgrade ) . and ( header :: exact_ignore_case ( " " , " " ) ) . and ( header :: exact ( " " , " " ) ) //.and(header::exact2(Upgrade::websocket())) //.and(header::exact2(SecWebsocketVersion::V13)) . and ( header :: header2 :: < SecWebsocketKey > ( ) ) . and ( body :: body ( ) ) . map ( move | key : SecWebsocketKey , body : :: hyper :: Body | { Ws2 { body , key , } } ) }
Creates a Websocket Filter.
Creates a Websocket Filter .
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.
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 .