rustdns 0.4.0

A DNS parsing library
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use http::HeaderValue;
use mime::Mime;
use std::str::FromStr;

pub(crate) fn content_type_equal(content_type: &HeaderValue, expected: &str) -> bool {
    // Parse the content type, into it's "essence" which is just "type/subtype", instead of
    // "type/subtype+suffix; param=value..."
    let content_type = match content_type.to_str() {
        Ok(t) => t,
        Err(_err) => return false,
    };
    let content_type = match Mime::from_str(content_type) {
        Ok(t) => t,
        Err(_err) => return false,
    };

    content_type.essence_str() == expected
}