mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-09 00:00:08 +02:00
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)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
use crate::io::util::DEFAULT_BUF_SIZE;
|
use crate::io::util::DEFAULT_BUF_SIZE;
|
||||||
use crate::io::{AsyncBufRead, AsyncRead, AsyncWrite};
|
use crate::io::{AsyncBufRead, AsyncRead, AsyncWrite};
|
||||||
|
|
||||||
|
use bytes::Buf;
|
||||||
use pin_project_lite::pin_project;
|
use pin_project_lite::pin_project;
|
||||||
use std::io::{self, Read};
|
use std::io::{self, Read};
|
||||||
use std::mem::MaybeUninit;
|
use std::mem::MaybeUninit;
|
||||||
@@ -162,6 +163,14 @@ impl<R: AsyncRead + AsyncWrite> AsyncWrite for BufReader<R> {
|
|||||||
self.get_pin_mut().poll_write(cx, buf)
|
self.get_pin_mut().poll_write(cx, buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn poll_write_buf<B: Buf>(
|
||||||
|
self: Pin<&mut Self>,
|
||||||
|
cx: &mut Context<'_>,
|
||||||
|
buf: &mut B,
|
||||||
|
) -> Poll<io::Result<usize>> {
|
||||||
|
self.get_pin_mut().poll_write_buf(cx, buf)
|
||||||
|
}
|
||||||
|
|
||||||
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
||||||
self.get_pin_mut().poll_flush(cx)
|
self.get_pin_mut().poll_flush(cx)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user