[diff] Corpus: 57 cases, all headers compared, narrow named divergences, misbehaving-auth and Upgrade-token cases
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user