Skip to content

Commit 5a3477a

Browse files
committed
feat: not return UnexpectedEof when server drops without close_notify
1 parent 27d1272 commit 5a3477a

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

src/proto/connection.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,7 @@ where
482482
// without error
483483
//
484484
// See https://github.com/hyperium/hyper/issues/3427
485-
if self.streams.is_server()
486-
&& self.streams.is_buffer_empty()
487-
&& matches!(kind, io::ErrorKind::UnexpectedEof)
488-
{
485+
if self.streams.is_buffer_empty() && matches!(kind, io::ErrorKind::UnexpectedEof) {
489486
*self.state = State::Closed(Reason::NO_ERROR, Initiator::Library);
490487
return Ok(());
491488
}

src/proto/streams/streams.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,6 @@ impl<B> DynStreams<'_, B> {
337337
self.send_buffer.is_empty()
338338
}
339339

340-
pub fn is_server(&self) -> bool {
341-
self.peer.is_server()
342-
}
343-
344340
pub fn recv_headers(&mut self, frame: frame::Headers) -> Result<(), Error> {
345341
let mut me = self.inner.lock().unwrap();
346342

tests/h2-tests/tests/client_request.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,7 +1914,7 @@ async fn receive_settings_frame_twice_with_second_one_non_empty() {
19141914
}
19151915

19161916
#[tokio::test]
1917-
async fn server_drop_connection_unexpectedly_return_unexpected_eof_err() {
1917+
async fn server_drop_connection_without_close_notify() {
19181918
h2_support::trace_init!();
19191919
let (io, mut srv) = mock::new();
19201920

@@ -1944,11 +1944,7 @@ async fn server_drop_connection_unexpectedly_return_unexpected_eof_err() {
19441944
.await
19451945
.expect("request");
19461946
});
1947-
let err = h2.await.expect_err("should receive UnexpectedEof");
1948-
assert_eq!(
1949-
err.get_io().expect("should be UnexpectedEof").kind(),
1950-
io::ErrorKind::UnexpectedEof,
1951-
);
1947+
let err = h2.await.unwrap();
19521948
};
19531949
join(srv, h2).await;
19541950
}

0 commit comments

Comments
 (0)