[diff] Corpus: 57 cases, all headers compared, narrow named divergences, misbehaving-auth and Upgrade-token cases

This commit is contained in:
2026-11-07 15:53:38 +01:00
parent a272e476b7
commit bcf94928c9
4 changed files with 381 additions and 150 deletions
+20 -2
View File
@@ -183,7 +183,11 @@ pub async fn http(addr: SocketAddr, req: &Req) -> io::Result<Resp> {
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum WsOutcome {
/// 101, the echoed message.
Upgraded { status: u16, echo: String },
Upgraded {
status: u16,
headers: Vec<(String, String)>,
echo: String,
},
/// The upgrade was answered with a normal HTTP response.
Refused(Resp),
}
@@ -212,6 +216,16 @@ pub async fn websocket(
match tokio_tungstenite::client_async(request, s).await {
Ok((mut ws, resp)) => {
let status = resp.status().as_u16();
let headers = resp
.headers()
.iter()
.map(|(n, v)| {
(
n.as_str().to_owned(),
String::from_utf8_lossy(v.as_bytes()).into_owned(),
)
})
.collect();
ws.send(tungstenite::Message::text(message))
.await
.map_err(other)?;
@@ -220,7 +234,11 @@ pub async fn websocket(
other_msg => return Err(other(format!("no echo: {other_msg:?}"))),
};
let _ = ws.close(None).await;
Ok(WsOutcome::Upgraded { status, echo })
Ok(WsOutcome::Upgraded {
status,
headers,
echo,
})
}
Err(tungstenite::Error::Http(resp)) => {
let status = resp.status().as_u16();