snapview / tokio-tungstenite

Future-based Tungstenite for Tokio. Lightweight stream-based WebSocket implementation
MIT License
1.88k stars 236 forks source link

Can we provided a way to keep the original header name case. #317

Open IWANABETHATGUY opened 10 months ago

IWANABETHATGUY commented 10 months ago
    let mut headers = request.headers_mut();

    headers. append(
        "Host",
        HeaderValue::from_static("report-worker-2.noscription.org"),
    );

    headers.insert("User-Agent", HeaderValue::from_str("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36").unwrap());

dbg!(&header);

this code print:

[src/main.rs:41] &request.headers() = {

    "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
}

Some servers require the header name is case-sensitive, which may cause some server internal errors.

daniel-abramov commented 10 months ago

This sounds like an issue that is very similar (if not same) to https://github.com/snapview/tungstenite-rs/pull/287

It's a bit complicated since that's how the underlying headers library behaved as far as I can recall. We'd need to find a workaround (essentially a kludge) if we want to make it work.