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

@@ -26,7 +26,7 @@ pub struct Handle {
}
#[derive(Debug)]
struct Pipe {
pub struct Pipe {
inner: Arc<Mutex<Inner>>,
}
@@ -67,6 +67,11 @@ pub fn new() -> (Mock, Handle) {
// ===== impl Handle =====
impl Handle {
/// Get a mutable reference to inner Codec.
pub fn codec_mut(&mut self) -> &mut ::Codec<Pipe> {
&mut self.codec
}
/// Send a frame
pub fn send(&mut self, item: SendFrame) -> Result<(), SendError> {
// Queue the frame
@@ -237,7 +242,7 @@ impl io::Write for Mock {
let mut me = self.pipe.inner.lock().unwrap();
if me.closed {
return Err(io::ErrorKind::BrokenPipe.into());
return Err(io::Error::new(io::ErrorKind::BrokenPipe, "mock closed"));
}
me.tx.extend(buf);