mirror of
https://github.com/actix/actix-web.git
synced 2025-04-07 10:39:36 +00:00
merge with msg-body
This commit is contained in:
commit
c3fce1c58b
2 changed files with 29 additions and 4 deletions
|
@ -379,7 +379,7 @@ where
|
|||
{
|
||||
pub fn new(stream: S) -> Self {
|
||||
BodyStream {
|
||||
stream,
|
||||
stream: Box::pin(stream),
|
||||
_t: PhantomData,
|
||||
}
|
||||
}
|
||||
|
@ -416,8 +416,7 @@ where
|
|||
#[pin_project]
|
||||
pub struct SizedStream<S: Unpin> {
|
||||
size: u64,
|
||||
#[pin]
|
||||
stream: S,
|
||||
stream: Pin<Box<S>>,
|
||||
}
|
||||
|
||||
impl<S> SizedStream<S>
|
||||
|
@ -425,7 +424,7 @@ where
|
|||
S: Stream<Item = Result<Bytes, Error>> + Unpin,
|
||||
{
|
||||
pub fn new(size: u64, stream: S) -> Self {
|
||||
SizedStream { size, stream }
|
||||
SizedStream { size, stream: Box::pin(stream) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
26
tests/test_weird_poll.rs
Normal file
26
tests/test_weird_poll.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Regression test for #/1321
|
||||
|
||||
use futures::task::{noop_waker, Context};
|
||||
use futures::stream::once;
|
||||
use actix_http::body::{MessageBody, BodyStream};
|
||||
use bytes::Bytes;
|
||||
|
||||
#[test]
|
||||
fn weird_poll() {
|
||||
let (sender, receiver) = futures::channel::oneshot::channel();
|
||||
let mut body_stream = Ok(BodyStream::new(once(async {
|
||||
let x = Box::new(0);
|
||||
let y = &x;
|
||||
receiver.await.unwrap();
|
||||
let _z = **y;
|
||||
Ok::<_, ()>(Bytes::new())
|
||||
})));
|
||||
|
||||
let waker = noop_waker();
|
||||
let mut context = Context::from_waker(&waker);
|
||||
|
||||
let _ = body_stream.as_mut().unwrap().poll_next(&mut context);
|
||||
sender.send(()).unwrap();
|
||||
let _ = std::mem::replace(&mut body_stream, Err([0; 32])).unwrap().poll_next(&mut context);
|
||||
}
|
||||
|
Loading…
Reference in a new issue