mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-26 06:57:43 +02:00
This is a squashed commit:
- Convert MessageBody to accept Pin in poll_next - add CHANGES and increase versions aligned to semver - update crates to accomodate MessageBody Pin change - fix tests and dependencies
This commit is contained in:
committed by
Yuki Okushi
parent
a4148de226
commit
9d04b250f9
@ -8,7 +8,7 @@ use bytes::buf::BufMutExt;
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use futures_core::Stream;
|
||||
use futures_util::future::poll_fn;
|
||||
use futures_util::{SinkExt, StreamExt};
|
||||
use futures_util::{SinkExt, StreamExt, pin_mut};
|
||||
|
||||
use crate::error::PayloadError;
|
||||
use crate::h1;
|
||||
@ -120,7 +120,7 @@ where
|
||||
|
||||
/// send request body to the peer
|
||||
pub(crate) async fn send_body<I, B>(
|
||||
mut body: B,
|
||||
body: B,
|
||||
framed: &mut Framed<I, h1::ClientCodec>,
|
||||
) -> Result<(), SendRequestError>
|
||||
where
|
||||
@ -128,9 +128,10 @@ where
|
||||
B: MessageBody,
|
||||
{
|
||||
let mut eof = false;
|
||||
pin_mut!(body);
|
||||
while !eof {
|
||||
while !eof && !framed.is_write_buf_full() {
|
||||
match poll_fn(|cx| body.poll_next(cx)).await {
|
||||
match poll_fn(|cx| body.as_mut().poll_next(cx)).await {
|
||||
Some(result) => {
|
||||
framed.write(h1::Message::Chunk(Some(result?)))?;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ use std::time;
|
||||
use actix_codec::{AsyncRead, AsyncWrite};
|
||||
use bytes::Bytes;
|
||||
use futures_util::future::poll_fn;
|
||||
use futures_util::pin_mut;
|
||||
use h2::{client::SendRequest, SendStream};
|
||||
use http::header::{HeaderValue, CONNECTION, CONTENT_LENGTH, TRANSFER_ENCODING};
|
||||
use http::{request::Request, Method, Version};
|
||||
@ -123,13 +124,14 @@ where
|
||||
}
|
||||
|
||||
async fn send_body<B: MessageBody>(
|
||||
mut body: B,
|
||||
body: B,
|
||||
mut send: SendStream<Bytes>,
|
||||
) -> Result<(), SendRequestError> {
|
||||
let mut buf = None;
|
||||
pin_mut!(body);
|
||||
loop {
|
||||
if buf.is_none() {
|
||||
match poll_fn(|cx| body.poll_next(cx)).await {
|
||||
match poll_fn(|cx| body.as_mut().poll_next(cx)).await {
|
||||
Some(Ok(b)) => {
|
||||
send.reserve_capacity(b.len());
|
||||
buf = Some(b);
|
||||
|
Reference in New Issue
Block a user