Make Codec max frame length configurable (#57)

This commit is contained in:
Eliza Weisman
2017-09-11 14:56:40 -05:00
committed by Carl Lerche
parent 460afa41c8
commit 11de86b34e
3 changed files with 67 additions and 3 deletions

View File

@@ -2,6 +2,8 @@
extern crate h2_test_support;
use h2_test_support::prelude::*;
use std::error::Error;
#[test]
fn read_none() {
let mut codec = Codec::from(
@@ -111,3 +113,22 @@ fn read_headers_with_pseudo() {
#[test]
fn read_headers_empty_payload() {
}
#[test]
fn update_max_frame_len_at_rest() {
// 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",
];
};
assert_eq!(poll_data!(codec).payload(), &b"hello"[..]);
codec.set_max_recv_frame_size(2);
assert_eq!(codec.max_recv_frame_size(), 2);
assert_eq!(codec.poll().unwrap_err().description(), "frame size too big");
}