let headers = std::mem::replace(&mut response.headers, hyper::header::Headers::new());
let content_length_header = headers.get_raw("Content-Length").unwrap();
I've been running into a similar issue with reqwest which is based on hyper and uses hyper's headers. I haven't found a way past it yet. I have this snippet of dealing with a response.
let mut n_bytes: u64 = 0;
match res.headers().get::<ContentLength>() {
Some(length) => { n_bytes = *length as u64; }
None => { println!("Content-Length header missing") }
}
Which is resulting in an error about non-scalar casts. Specifically:
error: non-scalar cast: reqwest::header::ContentLength as u64
Is there something I'm missing with regard to getting Content-Length header as a u64?