tur-rs 0.9.2

A relentless, high-concurrency download manager built for speed and efficiency. Tur uses dynamic work-stealing and aligned storage to saturate your bandwidth while maintaining a minuscule memory footprint. Inspired by the legends, built for the modern Rust ecosystem.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use http::HeaderMap;

pub fn parse_alt_svc_h3_port(headers: &HeaderMap) -> Option<u16> {
    let alt_svc = headers.get("alt-svc")?.to_str().ok()?;
    for token in alt_svc.split(',') {
        let token = token.trim();
        if token.starts_with("h3") && token.contains("\":") {
            if let Some(start) = token.find("\":") {
                let rest = &token[start + 2..];
                if let Some(end) = rest.find('"') {
                    return rest[..end].parse::<u16>().ok();
                }
            }
        }
    }
    None
}