in neqo-http3/src/server.rs [447:508]
fn connect_and_receive_settings_with_server(server: &mut Http3Server) -> Connection {
const CONTROL_STREAM_DATA: &[u8] = &[0x0, 0x4, 0x6, 0x1, 0x40, 0x64, 0x7, 0x40, 0x64];
let mut client = default_client();
connect_transport(server, &mut client, false);
let mut connected = false;
while let Some(e) = client.next_event() {
match e {
ConnectionEvent::NewStream { stream_id } => {
assert!(
(stream_id == SERVER_SIDE_CONTROL_STREAM_ID)
|| (stream_id == SERVER_SIDE_ENCODER_STREAM_ID)
|| (stream_id == SERVER_SIDE_DECODER_STREAM_ID)
);
assert_eq!(stream_id.stream_type(), StreamType::UniDi);
}
ConnectionEvent::RecvStreamReadable { stream_id } => {
if stream_id == CLIENT_SIDE_CONTROL_STREAM_ID
|| stream_id == SERVER_SIDE_CONTROL_STREAM_ID
{
// the control stream
let mut buf = [0_u8; 100];
let (amount, fin) = client.stream_recv(stream_id, &mut buf).unwrap();
assert!(!fin);
assert_eq!(amount, CONTROL_STREAM_DATA.len());
assert_eq!(&buf[..9], CONTROL_STREAM_DATA);
} else if stream_id == CLIENT_SIDE_ENCODER_STREAM_ID
|| stream_id == SERVER_SIDE_ENCODER_STREAM_ID
{
let mut buf = [0_u8; 100];
let (amount, fin) = client.stream_recv(stream_id, &mut buf).unwrap();
assert!(!fin);
assert_eq!(amount, 1);
assert_eq!(buf[..1], [0x2]);
} else if stream_id == CLIENT_SIDE_DECODER_STREAM_ID
|| stream_id == SERVER_SIDE_DECODER_STREAM_ID
{
let mut buf = [0_u8; 100];
let (amount, fin) = client.stream_recv(stream_id, &mut buf).unwrap();
assert!(!fin);
assert_eq!(amount, 1);
assert_eq!(buf[..1], [0x3]);
} else {
panic!("unexpected event");
}
}
ConnectionEvent::SendStreamWritable { stream_id } => {
assert!(
(stream_id == CLIENT_SIDE_CONTROL_STREAM_ID)
|| (stream_id == CLIENT_SIDE_ENCODER_STREAM_ID)
|| (stream_id == CLIENT_SIDE_DECODER_STREAM_ID)
);
}
ConnectionEvent::StateChange(State::Connected) => connected = true,
ConnectionEvent::StateChange(_) | ConnectionEvent::SendStreamCreatable { .. } => (),
_ => panic!("unexpected event"),
}
}
assert!(connected);
client
}