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

@@ -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(())
}