Skip to content

Commit

Permalink
Section 5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
fasterthanlime committed Jun 1, 2024
1 parent de9432d commit 0a9ab86
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
14 changes: 14 additions & 0 deletions crates/httpwg-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,20 @@ macro_rules! tests {
$body
}
}

/// Section 5.5: Extending HTTP/2
mod _5_5_extending_http2 {
use super::__suite::_5_5_extending_http2 as __group;

/// Extension frames that appear in the middle of a header block
/// (Section 4.3) are not permitted; these MUST be treated as
/// a connection error (Section 5.4.1) of type PROTOCOL_ERROR.
#[test]
fn unknown_extension_frame_in_header_block() {
use __group::unknown_extension_frame_in_header_block as test;
$body
}
}
}
};
}
39 changes: 39 additions & 0 deletions crates/httpwg/src/rfc9113/_5_5_extending_http2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//! Section 5.5: Extending HTTP/2
use fluke_buffet::IntoHalves;
use fluke_h2_parse::{EncodedFrameType, Frame, FrameType, HeadersFlags, StreamId};

use crate::{Conn, ErrorC};

/// Extension frames that appear in the middle of a header block
/// (Section 4.3) are not permitted; these MUST be treated as
/// a connection error (Section 5.4.1) of type PROTOCOL_ERROR.
pub async fn unknown_extension_frame_in_header_block<IO: IntoHalves + 'static>(
mut conn: Conn<IO>,
) -> eyre::Result<()> {
let stream_id = StreamId(1);

conn.handshake().await?;

let headers = conn.common_headers();
let block_fragment = conn.encode_headers(&headers)?;

conn.write_headers(stream_id, HeadersFlags::EndStream, block_fragment)
.await?;

conn.write_frame(
Frame {
frame_type: FrameType::Unknown(EncodedFrameType {
ty: 0xff,
flags: 0x0,
}),
..Default::default()
},
b"0".repeat(8),
)
.await?;

conn.verify_connection_error(ErrorC::ProtocolError).await?;

Ok(())
}
2 changes: 2 additions & 0 deletions crates/httpwg/src/rfc9113/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ pub mod _5_1_2_stream_concurrency;
pub mod _5_3_1_stream_dependencies;

pub mod _5_4_1_connection_error_handling;

pub mod _5_5_extending_http2;

0 comments on commit 0a9ab86

Please sign in to comment.