add support for configuring max frame size
- Adds `max_frame_size` to client and server builders - Pushes max_frame_size into Codec - Detects when the Codec triggers an error from a frame too big - Sends a GOAWAY when FRAME_SIZE_ERROR is encountered reading a frame
This commit is contained in:
@@ -110,22 +110,24 @@ fn read_headers_empty_payload() {}
|
||||
|
||||
#[test]
|
||||
fn update_max_frame_len_at_rest() {
|
||||
let _ = ::env_logger::init();
|
||||
// TODO: add test for updating max frame length in flight as well?
|
||||
let mut codec = raw_codec! {
|
||||
read => [
|
||||
0, 0, 5, 0, 0, 0, 0, 0, 1,
|
||||
"hello",
|
||||
"world",
|
||||
0, 64, 1, 0, 0, 0, 0, 0, 1,
|
||||
vec![0; 16_385],
|
||||
];
|
||||
};
|
||||
|
||||
assert_eq!(poll_data!(codec).payload(), &b"hello"[..]);
|
||||
|
||||
codec.set_max_recv_frame_size(2);
|
||||
codec.set_max_recv_frame_size(16_384);
|
||||
|
||||
assert_eq!(codec.max_recv_frame_size(), 2);
|
||||
assert_eq!(codec.max_recv_frame_size(), 16_384);
|
||||
assert_eq!(
|
||||
codec.poll().unwrap_err().description(),
|
||||
"frame size too big"
|
||||
"frame with invalid size"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user