Handle client-disabled server push (#486)

This commit is contained in:
eggyal
2020-09-18 01:25:31 +01:00
committed by GitHub
parent a19323727b
commit 2b19acf132
6 changed files with 70 additions and 3 deletions

View File

@@ -86,7 +86,7 @@ where
.unwrap_or(DEFAULT_INITIAL_WINDOW_SIZE),
initial_max_send_streams: config.initial_max_send_streams,
local_next_stream_id: config.next_stream_id,
local_push_enabled: config.settings.is_push_enabled(),
local_push_enabled: config.settings.is_push_enabled().unwrap_or(true),
local_reset_duration: config.reset_stream_duration,
local_reset_max: config.reset_stream_max,
remote_init_window_sz: DEFAULT_INITIAL_WINDOW_SIZE,

View File

@@ -32,6 +32,8 @@ pub(super) struct Send {
/// Prioritization layer
prioritize: Prioritize,
is_push_enabled: bool,
}
/// A value to detect which public API has called `poll_reset`.
@@ -49,6 +51,7 @@ impl Send {
max_stream_id: StreamId::MAX,
next_stream_id: Ok(config.local_next_stream_id),
prioritize: Prioritize::new(config),
is_push_enabled: true,
}
}
@@ -95,6 +98,10 @@ impl Send {
stream: &mut store::Ptr,
task: &mut Option<Waker>,
) -> Result<(), UserError> {
if !self.is_push_enabled {
return Err(UserError::PeerDisabledServerPush);
}
tracing::trace!(
"send_push_promise; frame={:?}; init_window={:?}",
frame,
@@ -496,6 +503,10 @@ impl Send {
}
}
if let Some(val) = settings.is_push_enabled() {
self.is_push_enabled = val
}
Ok(())
}