From 4261cab3a589ba1c1aeec73c20dd97952111f95a Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 21 Apr 2021 16:36:06 +0100 Subject: [PATCH] fix fix msrv --- actix-http/src/body/body.rs | 14 +++++++++++--- actix-http/src/body/message_body.rs | 14 ++++++++++---- actix-http/src/encoding/encoder.rs | 6 +++++- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/actix-http/src/body/body.rs b/actix-http/src/body/body.rs index ff4ff3292..c86bf9234 100644 --- a/actix-http/src/body/body.rs +++ b/actix-http/src/body/body.rs @@ -7,7 +7,7 @@ use std::{ }; use bytes::{Bytes, BytesMut}; -use futures_core::Stream; +use futures_core::{ready, Stream}; use crate::error::Error; @@ -72,7 +72,11 @@ impl MessageBody for Body { Poll::Ready(Some(Ok(mem::take(bin)))) } } - Body::Message(body) => body.as_mut().poll_next(cx).map_err(Into::into), + Body::Message(body) => match ready!(body.as_mut().poll_next(cx)) { + Some(Err(err)) => Poll::Ready(Some(Err(err.into()))), + Some(Ok(val)) => Poll::Ready(Some(Ok(val))), + None => Poll::Ready(None), + }, } } } @@ -212,6 +216,10 @@ impl MessageBody for BoxAnyBody { mut self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll>> { - self.0.as_mut().poll_next(cx).map_err(Into::into) + match ready!(self.0.as_mut().poll_next(cx)) { + Some(Err(err)) => Poll::Ready(Some(Err(err.into()))), + Some(Ok(val)) => Poll::Ready(Some(Ok(val))), + None => Poll::Ready(None), + } } } diff --git a/actix-http/src/body/message_body.rs b/actix-http/src/body/message_body.rs index bb1bc7e18..4a7f7171f 100644 --- a/actix-http/src/body/message_body.rs +++ b/actix-http/src/body/message_body.rs @@ -7,6 +7,7 @@ use std::{ }; use bytes::{Bytes, BytesMut}; +use futures_core::ready; use pin_project_lite::pin_project; use crate::error::Error; @@ -212,9 +213,14 @@ where ) -> Poll>> { let this = self.as_mut().project(); - this.body.poll_next(cx).map_err(|err| { - let f = self.as_mut().project().mapper.take().unwrap(); - (f)(err) - }) + match ready!(this.body.poll_next(cx)) { + Some(Err(err)) => { + let f = self.as_mut().project().mapper.take().unwrap(); + let mapped_err = (f)(err); + Poll::Ready(Some(Err(mapped_err))) + } + Some(Ok(val)) => Poll::Ready(Some(Ok(val))), + None => Poll::Ready(None), + } } } diff --git a/actix-http/src/encoding/encoder.rs b/actix-http/src/encoding/encoder.rs index d5525f985..c41f79242 100644 --- a/actix-http/src/encoding/encoder.rs +++ b/actix-http/src/encoding/encoder.rs @@ -120,7 +120,11 @@ impl> MessageBody for EncoderBody { } EncoderBodyProj::Stream(b) => b.poll_next(cx), EncoderBodyProj::BoxedStream(ref mut b) => { - b.as_mut().poll_next(cx).map_err(Into::into) + match ready!(b.as_mut().poll_next(cx)) { + Some(Err(err)) => Poll::Ready(Some(Err(err.into()))), + Some(Ok(val)) => Poll::Ready(Some(Ok(val))), + None => Poll::Ready(None), + } } } }