pub fn exact_ignore_case(
    name: &'static str,
    value: &'static str
) -> impl Filter<Extract = (), Error = Rejection> + Copy
Expand description

Create a Filter that requires a header to match the value exactly.

This Filter will look for a header with supplied name and the exact value, ignoring ASCII case, otherwise rejects the request.

Example

// Require `connection: keep-alive` header to be set.
let keep_alive = warp::header::exact_ignore_case("connection", "keep-alive");
Examples found in repository?
src/filters/ws.rs (line 56)
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
pub fn ws() -> impl Filter<Extract = One<Ws>, Error = Rejection> + Copy {
    let connection_has_upgrade = header::header2()
        .and_then(|conn: ::headers::Connection| {
            if conn.contains("upgrade") {
                future::ok(())
            } else {
                future::err(crate::reject::known(MissingConnectionUpgrade))
            }
        })
        .untuple_one();

    crate::get()
        .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(on_upgrade())
        .map(
            move |key: SecWebsocketKey, on_upgrade: Option<OnUpgrade>| Ws {
                config: None,
                key,
                on_upgrade,
            },
        )
}