xmlstream: improve responder-side of stream resets

This makes the stream resets a lot safer, by preventing the forbidden
send-read-reset combination of events: the reset function on the
responder side now takes the element to send right before the reset,
enforcing a send-reset pattern.
This commit is contained in:
Jonas Schäfer 2024-08-14 18:05:05 +02:00
commit c85c98b0bf
2 changed files with 42 additions and 10 deletions

View file

@ -220,16 +220,15 @@ async fn test_exchange_data_stream_reset_and_shutdown() {
let mut stream = stream
.send_features::<Data>(&StreamFeatures::default())
.await?;
stream
.send(&Data {
contents: "world!".to_owned(),
})
.await?;
match stream.next().await {
Some(Ok(Data { contents })) => assert_eq!(contents, "hello"),
other => panic!("unexpected stream message: {:?}", other),
}
let stream = stream.accept_reset().await?;
let stream = stream
.accept_reset(&Data {
contents: "world!".to_owned(),
})
.await?;
assert_eq!(stream.header().from.unwrap(), "client");
assert_eq!(stream.header().to.unwrap(), "server");
assert_eq!(stream.header().id.unwrap(), "client-id");