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:
Sean McArthur
2017-09-13 14:10:27 -07:00
parent 8984a46a92
commit c32015d48e
13 changed files with 221 additions and 18 deletions

View File

@@ -170,6 +170,12 @@ impl Builder {
self
}
/// Set the max frame size of received frames.
pub fn max_frame_size(&mut self, max: u32) -> &mut Self {
self.settings.set_max_frame_size(Some(max));
self
}
/// Bind an H2 client connection.
///
/// Returns a future which resolves to the connection value once the H2
@@ -203,6 +209,10 @@ where
// Create the codec
let mut codec = Codec::new(io);
if let Some(max) = self.settings.max_frame_size() {
codec.set_max_recv_frame_size(max as usize);
}
// Send initial settings frame
codec
.buffer(self.settings.clone().into())