Skip to content

Commit be08648

Browse files
authoredAug 19, 2021
fix(http2): improve errors emitted by HTTP2 Upgraded stream shutdown (#2622)
1 parent 9a113ed commit be08648

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed
 

‎src/proto/h2/mod.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,24 @@ where
377377

378378
fn poll_shutdown(
379379
mut self: Pin<&mut Self>,
380-
_cx: &mut Context<'_>,
380+
cx: &mut Context<'_>,
381381
) -> Poll<Result<(), io::Error>> {
382-
Poll::Ready(self.send_stream.write(&[], true))
382+
if self.send_stream.write(&[], true).is_ok() {
383+
return Poll::Ready(Ok(()))
384+
}
385+
386+
Poll::Ready(Err(h2_to_io_error(
387+
match ready!(self.send_stream.poll_reset(cx)) {
388+
Ok(Reason::NO_ERROR) => {
389+
return Poll::Ready(Ok(()))
390+
}
391+
Ok(Reason::CANCEL) | Ok(Reason::STREAM_CLOSED) => {
392+
return Poll::Ready(Err(io::ErrorKind::BrokenPipe.into()))
393+
}
394+
Ok(reason) => reason.into(),
395+
Err(e) => e,
396+
},
397+
)))
383398
}
384399
}
385400

0 commit comments

Comments
 (0)
Please sign in to comment.