Skip to content

Commit 785c8cc

Browse files
committed
fix: avoid unwrapping for the Future impl of UpgradeableConnection
Closes hyperium#3621
1 parent 203d1b0 commit 785c8cc

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/server/conn/http1.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -501,14 +501,18 @@ where
501501
type Output = crate::Result<()>;
502502

503503
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
504-
match ready!(Pin::new(&mut self.inner.as_mut().unwrap().conn).poll(cx)) {
505-
Ok(proto::Dispatched::Shutdown) => Poll::Ready(Ok(())),
506-
Ok(proto::Dispatched::Upgrade(pending)) => {
507-
let (io, buf, _) = self.inner.take().unwrap().conn.into_inner();
508-
pending.fulfill(Upgraded::new(io, buf));
509-
Poll::Ready(Ok(()))
504+
if let Some(conn) = self.inner.as_mut() {
505+
match ready!(Pin::new(&mut conn.conn).poll(cx)) {
506+
Ok(proto::Dispatched::Shutdown) => Poll::Ready(Ok(())),
507+
Ok(proto::Dispatched::Upgrade(pending)) => {
508+
let (io, buf, _) = self.inner.take().unwrap().conn.into_inner();
509+
pending.fulfill(Upgraded::new(io, buf));
510+
Poll::Ready(Ok(()))
511+
}
512+
Err(e) => Poll::Ready(Err(e)),
510513
}
511-
Err(e) => Poll::Ready(Err(e)),
514+
} else {
515+
Poll::Ready(Ok(()))
512516
}
513517
}
514518
}

0 commit comments

Comments
 (0)