Add ability to adjust INITIAL_WINDOW_SIZE setting on an existing connection (#421)

This commit is contained in:
Sean McArthur
2019-10-07 15:29:23 -07:00
committed by GitHub
parent 367206bfa1
commit 4c1d797712
10 changed files with 439 additions and 27 deletions

View File

@@ -1,4 +1,4 @@
use crate::codec::RecvError;
use crate::codec::{RecvError, UserError};
use crate::frame::{Reason, StreamId};
use crate::{client, frame, proto, server};
@@ -99,16 +99,24 @@ where
codec,
go_away: GoAway::new(),
ping_pong: PingPong::new(),
settings: Settings::new(),
settings: Settings::new(config.settings),
streams,
_phantom: PhantomData,
}
}
pub fn set_target_window_size(&mut self, size: WindowSize) {
/// connection flow control
pub(crate) fn set_target_window_size(&mut self, size: WindowSize) {
self.streams.set_target_connection_window_size(size);
}
/// Send a new SETTINGS frame with an updated initial window size.
pub(crate) fn set_initial_window_size(&mut self, size: WindowSize) -> Result<(), UserError> {
let mut settings = frame::Settings::default();
settings.set_initial_window_size(Some(size));
self.settings.send_settings(settings)
}
/// Returns `Ready` when the connection is ready to receive a frame.
///
/// Returns `RecvError` as this may raise errors that are caused by delayed
@@ -119,7 +127,7 @@ where
ready!(self.ping_pong.send_pending_ping(cx, &mut self.codec))?;
ready!(self
.settings
.send_pending_ack(cx, &mut self.codec, &mut self.streams))?;
.poll_send(cx, &mut self.codec, &mut self.streams))?;
ready!(self.streams.send_pending_refusal(cx, &mut self.codec))?;
Poll::Ready(Ok(()))
@@ -327,7 +335,8 @@ where
}
Some(Settings(frame)) => {
log::trace!("recv SETTINGS; frame={:?}", frame);
self.settings.recv_settings(frame);
self.settings
.recv_settings(frame, &mut self.codec, &mut self.streams)?;
}
Some(GoAway(frame)) => {
log::trace!("recv GOAWAY; frame={:?}", frame);