Skip to content

Commit dd28831

Browse files
authored
io: Forward poll_write_buf on BufReader (#2654)
For some yet unknown reason using the default on a wrapped `Bufreader<TcpStream>` causes the hyper server to sometimes fail to send the entire body in the response. This fixes that problem for us and ensures that hyper has a chance to use vectored IO (making it a good change regardless of the mentioned bug)
1 parent 6dcce19 commit dd28831

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tokio/src/io/util/buf_reader.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::io::util::DEFAULT_BUF_SIZE;
22
use crate::io::{AsyncBufRead, AsyncRead, AsyncWrite};
33

4+
use bytes::Buf;
45
use pin_project_lite::pin_project;
56
use std::io::{self, Read};
67
use std::mem::MaybeUninit;
@@ -162,6 +163,14 @@ impl<R: AsyncRead + AsyncWrite> AsyncWrite for BufReader<R> {
162163
self.get_pin_mut().poll_write(cx, buf)
163164
}
164165

166+
fn poll_write_buf<B: Buf>(
167+
self: Pin<&mut Self>,
168+
cx: &mut Context<'_>,
169+
buf: &mut B,
170+
) -> Poll<io::Result<usize>> {
171+
self.get_pin_mut().poll_write_buf(cx, buf)
172+
}
173+
165174
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
166175
self.get_pin_mut().poll_flush(cx)
167176
}

0 commit comments

Comments
 (0)