1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-26 06:57:43 +02:00

remove internal usage of Body

This commit is contained in:
Rob Ede
2021-11-16 22:10:30 +00:00
parent d8cbb879dd
commit 668a33c793
23 changed files with 137 additions and 111 deletions

View File

@ -8,7 +8,7 @@ use std::{
use actix_codec::Framed;
use actix_http::{
body::Body, h1::ClientCodec, Payload, RequestHead, RequestHeadType, ResponseHead,
body::AnyBody, h1::ClientCodec, Payload, RequestHead, RequestHeadType, ResponseHead,
};
use actix_service::Service;
use futures_core::{future::LocalBoxFuture, ready};
@ -30,7 +30,7 @@ pub type BoxConnectorService = Rc<
pub type BoxedSocket = Box<dyn ConnectionIo>;
pub enum ConnectRequest {
Client(RequestHeadType, Body, Option<net::SocketAddr>),
Client(RequestHeadType, AnyBody, Option<net::SocketAddr>),
Tunnel(RequestHead, Option<net::SocketAddr>),
}

View File

@ -5,7 +5,7 @@ use futures_core::Stream;
use serde::Serialize;
use actix_http::{
body::Body,
body::AnyBody,
http::{header::IntoHeaderValue, Error as HttpError, HeaderMap, HeaderName, Method, Uri},
RequestHead,
};
@ -45,7 +45,7 @@ impl FrozenClientRequest {
/// Send a body.
pub fn send_body<B>(&self, body: B) -> SendClientRequest
where
B: Into<Body>,
B: Into<AnyBody>,
{
RequestSender::Rc(self.head.clone(), None).send_body(
self.addr,
@ -158,7 +158,7 @@ impl FrozenSendBuilder {
/// Complete request construction and send a body.
pub fn send_body<B>(self, body: B) -> SendClientRequest
where
B: Into<Body>,
B: Into<AnyBody>,
{
if let Some(e) = self.err {
return e.into();

View File

@ -8,7 +8,7 @@ use std::{
};
use actix_http::{
body::Body,
body::AnyBody,
http::{header, Method, StatusCode, Uri},
RequestHead, RequestHeadType,
};
@ -95,7 +95,7 @@ where
};
let body_opt = match body {
Body::Bytes(ref b) => Some(b.clone()),
AnyBody::Bytes(ref b) => Some(b.clone()),
_ => None,
};
@ -192,14 +192,14 @@ where
let body_new = if is_redirect {
// try to reuse body
match body {
Some(ref bytes) => Body::Bytes(bytes.clone()),
// TODO: should this be Body::Empty or Body::None.
_ => Body::empty(),
Some(ref bytes) => AnyBody::Bytes(bytes.clone()),
// TODO: should this be AnyBody::Empty or AnyBody::None.
_ => AnyBody::empty(),
}
} else {
body = None;
// remove body
Body::None
AnyBody::None
};
let mut headers = headers.take().unwrap();

View File

@ -5,7 +5,7 @@ use futures_core::Stream;
use serde::Serialize;
use actix_http::{
body::Body,
body::AnyBody,
http::{
header::{self, IntoHeaderPair},
ConnectionType, Error as HttpError, HeaderMap, HeaderValue, Method, Uri, Version,
@ -350,7 +350,7 @@ impl ClientRequest {
/// Complete request construction and send body.
pub fn send_body<B>(self, body: B) -> SendClientRequest
where
B: Into<Body>,
B: Into<AnyBody>,
{
let slf = match self.prep_for_sending() {
Ok(slf) => slf,

View File

@ -9,7 +9,7 @@ use std::{
};
use actix_http::{
body::{AnyBody, Body, BodyStream},
body::{AnyBody, BodyStream},
http::{
header::{self, HeaderMap, HeaderName, IntoHeaderValue},
Error as HttpError,
@ -196,7 +196,7 @@ impl RequestSender {
body: B,
) -> SendClientRequest
where
B: Into<Body>,
B: Into<AnyBody>,
{
let req = match self {
RequestSender::Owned(head) => {
@ -236,7 +236,7 @@ impl RequestSender {
response_decompress,
timeout,
config,
Body::Bytes(Bytes::from(body)),
AnyBody::Bytes(Bytes::from(body)),
)
}
@ -265,7 +265,7 @@ impl RequestSender {
response_decompress,
timeout,
config,
Body::Bytes(Bytes::from(body)),
AnyBody::Bytes(Bytes::from(body)),
)
}
@ -297,7 +297,7 @@ impl RequestSender {
timeout: Option<Duration>,
config: &ClientConfig,
) -> SendClientRequest {
self.send_body(addr, response_decompress, timeout, config, Body::empty())
self.send_body(addr, response_decompress, timeout, config, AnyBody::empty())
}
fn set_header_if_none<V>(&mut self, key: HeaderName, value: V) -> Result<(), HttpError>