refactor(http1): move upgrade state from body to head (#2353)
Move state required for protocol upgrades to head representations, instead of associating it with the body. Closes #2340. Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
@@ -317,26 +317,34 @@ mod sealed {
|
||||
}
|
||||
|
||||
impl CanUpgrade for http::Request<crate::Body> {
|
||||
fn on_upgrade(self) -> OnUpgrade {
|
||||
self.into_body().take_upgrade()
|
||||
fn on_upgrade(mut self) -> OnUpgrade {
|
||||
self.extensions_mut()
|
||||
.remove::<OnUpgrade>()
|
||||
.unwrap_or_else(OnUpgrade::none)
|
||||
}
|
||||
}
|
||||
|
||||
impl CanUpgrade for &'_ mut http::Request<crate::Body> {
|
||||
fn on_upgrade(self) -> OnUpgrade {
|
||||
self.body_mut().take_upgrade()
|
||||
self.extensions_mut()
|
||||
.remove::<OnUpgrade>()
|
||||
.unwrap_or_else(OnUpgrade::none)
|
||||
}
|
||||
}
|
||||
|
||||
impl CanUpgrade for http::Response<crate::Body> {
|
||||
fn on_upgrade(self) -> OnUpgrade {
|
||||
self.into_body().take_upgrade()
|
||||
fn on_upgrade(mut self) -> OnUpgrade {
|
||||
self.extensions_mut()
|
||||
.remove::<OnUpgrade>()
|
||||
.unwrap_or_else(OnUpgrade::none)
|
||||
}
|
||||
}
|
||||
|
||||
impl CanUpgrade for &'_ mut http::Response<crate::Body> {
|
||||
fn on_upgrade(self) -> OnUpgrade {
|
||||
self.body_mut().take_upgrade()
|
||||
self.extensions_mut()
|
||||
.remove::<OnUpgrade>()
|
||||
.unwrap_or_else(OnUpgrade::none)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user