1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-21 05:05:44 +02:00

body ergonomics v3 (#2468)

This commit is contained in:
Rob Ede
2021-12-04 19:40:47 +00:00
committed by GitHub
parent a2d5c5a058
commit c7c02ef99d
84 changed files with 2134 additions and 1685 deletions

View File

@@ -8,7 +8,6 @@ use std::{
};
use actix_http::{
body::AnyBody,
http::{header, Method, StatusCode, Uri},
RequestHead, RequestHeadType,
};
@@ -17,10 +16,12 @@ use bytes::Bytes;
use futures_core::ready;
use super::Transform;
use crate::client::{InvalidUrl, SendRequestError};
use crate::connect::{ConnectRequest, ConnectResponse};
use crate::ClientResponse;
use crate::{
any_body::AnyBody,
client::{InvalidUrl, SendRequestError},
connect::{ConnectRequest, ConnectResponse},
ClientResponse,
};
pub struct Redirect {
max_redirect_times: u8,
@@ -95,7 +96,7 @@ where
};
let body_opt = match body {
AnyBody::Bytes(ref b) => Some(b.clone()),
AnyBody::Bytes { ref body } => Some(body.clone()),
_ => None,
};
@@ -192,7 +193,9 @@ where
let body_new = if is_redirect {
// try to reuse body
match body {
Some(ref bytes) => AnyBody::Bytes(bytes.clone()),
Some(ref bytes) => AnyBody::Bytes {
body: bytes.clone(),
},
// TODO: should this be AnyBody::Empty or AnyBody::None.
_ => AnyBody::empty(),
}