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

remove responsebody indirection from response (#2201)

This commit is contained in:
Rob Ede
2021-05-09 20:12:48 +01:00
committed by GitHub
parent a9dc1586a0
commit 900c9e270e
31 changed files with 381 additions and 263 deletions

View File

@@ -10,7 +10,7 @@ use std::{
};
use actix_http::{
body::MessageBody,
body::{MessageBody, ResponseBody},
encoding::Encoder,
http::header::{ContentEncoding, ACCEPT_ENCODING},
Error,
@@ -59,7 +59,7 @@ where
B: MessageBody,
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
{
type Response = ServiceResponse<Encoder<B>>;
type Response = ServiceResponse<ResponseBody<Encoder<B>>>;
type Error = Error;
type Transform = CompressMiddleware<S>;
type InitError = ();
@@ -83,7 +83,7 @@ where
B: MessageBody,
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
{
type Response = ServiceResponse<Encoder<B>>;
type Response = ServiceResponse<ResponseBody<Encoder<B>>>;
type Error = Error;
type Future = CompressResponse<S, B>;
@@ -127,7 +127,7 @@ where
B: MessageBody,
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
{
type Output = Result<ServiceResponse<Encoder<B>>, Error>;
type Output = Result<ServiceResponse<ResponseBody<Encoder<B>>>, Error>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.project();
@@ -140,9 +140,9 @@ where
*this.encoding
};
Poll::Ready(Ok(
resp.map_body(move |head, body| Encoder::response(enc, head, body))
))
Poll::Ready(Ok(resp.map_body(move |head, body| {
Encoder::response(enc, head, ResponseBody::Body(body))
})))
}
Err(e) => Poll::Ready(Err(e)),
}