1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-07-01 16:55:08 +02:00

remove unpin from body types (#2152)

This commit is contained in:
Rob Ede
2021-04-13 11:16:12 +01:00
committed by GitHub
parent ce50cc9523
commit edd9f14752
19 changed files with 241 additions and 194 deletions

View File

@ -1,6 +1,7 @@
use std::fmt;
use actix_http::{
body::Body,
error::InternalError,
http::{header::IntoHeaderPair, Error as HttpError, HeaderMap, StatusCode},
};
@ -65,7 +66,7 @@ impl Responder for HttpResponse {
}
}
impl Responder for actix_http::Response {
impl Responder for actix_http::Response<Body> {
#[inline]
fn respond_to(self, _: &HttpRequest) -> HttpResponse {
HttpResponse::from(self)

View File

@ -3,6 +3,7 @@ use std::{
convert::TryInto,
fmt,
future::Future,
mem,
pin::Pin,
task::{Context, Poll},
};
@ -287,18 +288,17 @@ impl<B> From<HttpResponse<B>> for Response<B> {
}
impl Future for HttpResponse {
type Output = Result<Response, Error>;
type Output = Result<Response<Body>, Error>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
fn poll(mut self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> {
if let Some(err) = self.error.take() {
eprintln!("httpresponse future error");
return Poll::Ready(Ok(Response::from_error(err).into_body()));
}
let res = &mut self.res;
actix_rt::pin!(res);
res.poll(cx)
Poll::Ready(Ok(mem::replace(
&mut self.res,
Response::new(StatusCode::default()),
)))
}
}
@ -680,7 +680,7 @@ impl From<HttpResponseBuilder> for HttpResponse {
}
}
impl From<HttpResponseBuilder> for Response {
impl From<HttpResponseBuilder> for Response<Body> {
fn from(mut builder: HttpResponseBuilder) -> Self {
builder.finish().into()
}