Skip to content

Commit

Permalink
Include a test for setting header_table_size
Browse files Browse the repository at this point in the history
  • Loading branch information
4JX committed Aug 24, 2022
1 parent 4e6d835 commit 7af4adf
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/h2-support/src/frames.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ impl Mock<frame::Settings> {
self.0.set_enable_connect_protocol(Some(val));
self
}

pub fn header_table_size(mut self, val: u32) -> Self {
self.0.set_header_table_size(Some(val));
self
}
}

impl From<Mock<frame::Settings>> for frame::Settings {
Expand Down
34 changes: 34 additions & 0 deletions tests/h2-tests/tests/client_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,40 @@ async fn extended_connect_request() {
join(srv, h2).await;
}

#[tokio::test]
async fn client_builder_header_table_size() {
h2_support::trace_init!();
let (io, mut srv) = mock::new();
let mut settings = frame::Settings::default();

settings.set_header_table_size(Some(10000));

let srv = async move {
let recv_settings = srv.assert_client_handshake().await;
assert_frame_eq(recv_settings, settings);

srv.recv_frame(
frames::headers(1)
.request("GET", "https://example.com/")
.eos(),
)
.await;
srv.send_frame(frames::headers(1).response(200).eos()).await;
};

let mut builder = client::Builder::new();
builder.header_table_size(10000);

let h2 = async move {
let (mut client, mut h2) = builder.handshake::<_, Bytes>(io).await.unwrap();
let request = Request::get("https://example.com/").body(()).unwrap();
let (response, _) = client.send_request(request, true).unwrap();
h2.drive(response).await.unwrap();
};

join(srv, h2).await;
}

const SETTINGS: &'static [u8] = &[0, 0, 0, 4, 0, 0, 0, 0, 0];
const SETTINGS_ACK: &'static [u8] = &[0, 0, 0, 4, 1, 0, 0, 0, 0];

Expand Down

0 comments on commit 7af4adf

Please sign in to comment.