/// A helper function that prepares the headers that should be sent in an HTTP/2 message.
///
/// Adapts the `Headers` into a list of octet string pairs.
A helper function that prepares the headers that should be sent in an HTTP/2 message.
Adapts the `Headers` into a list of octet string pairs.
A helper function that prepares the headers that should be sent in an HTTP / 2 message . Adapts the ` Headers ` into a list of octet string pairs .
fn prepare_headers(mut headers: Headers) -> Vec<Http2Header> {
    if headers.remove::<header::Connection>() {
        warn!("The `Connection` header is not valid for an HTTP/2 connection.");
    }
    let mut http2_headers: Vec<_> = headers.iter().filter_map(|h| {
        if h.is::<header::SetCookie>() {
            None
        } else {
            // HTTP/2 header names MUST be lowercase.
            Some((h.name().to_ascii_lowercase().into_bytes(), h.value_string().into_bytes()))
        }
    }).collect();
    // Now separately add the cookies, as `hyper` considers `Set-Cookie` to be only a single
    // header, even in the face of multiple cookies being set.
    if let Some(set_cookie) = headers.get::<header::SetCookie>() {
        for cookie in set_cookie.iter() {
            http2_headers.push((b"set-cookie".to_vec(), cookie.to_string().into_bytes()));
        }
    }
    http2_headers
}
fn prepare_headers ( mut headers : Headers ) -> Vec < Http2Header > { if headers . remove :: < header :: Connection > ( ) { warn ! ( " " ) ; } let mut http2_headers : Vec < _ > = headers . iter ( ) . filter_map ( | h | { if h . is :: < header :: SetCookie > ( ) { None } else { // HTTP/2 header names MUST be lowercase. Some ( ( h . name ( ) . to_ascii_lowercase ( ) . into_bytes ( ) , h . value_string ( ) . into_bytes ( ) ) ) } } ) . collect ( ) ; // Now separately add the cookies, as `hyper` considers `Set-Cookie` to be only a single // header, even in the face of multiple cookies being set. if let Some ( set_cookie ) = headers . get :: < header :: SetCookie > ( ) { for cookie in set_cookie . iter ( ) { http2_headers . push ( ( b" " . to_vec ( ) , cookie . to_string ( ) . into_bytes ( ) ) ) ; } } http2_headers }
A helper function that prepares the headers that should be sent in an HTTP/2 message.
A helper function that prepares the headers that should be sent in an HTTP / 2 message .
headers
Headers