mirror of https://github.com/fafhrd91/actix-web
re purpose pr
This commit is contained in:
parent
05ba1c5681
commit
2de3b542bd
|
@ -387,6 +387,12 @@ impl BoxedResponseHead {
|
||||||
pub fn new(status: StatusCode) -> Self {
|
pub fn new(status: StatusCode) -> Self {
|
||||||
RESPONSE_POOL.with(|p| p.get_message(status))
|
RESPONSE_POOL.with(|p| p.get_message(status))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn take(&mut self) -> Self {
|
||||||
|
BoxedResponseHead {
|
||||||
|
head: self.head.take(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::ops::Deref for BoxedResponseHead {
|
impl std::ops::Deref for BoxedResponseHead {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
//! Http response
|
//! Http response
|
||||||
use std::cell::{Ref, RefMut};
|
use std::cell::{Ref, RefMut};
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
use std::future::Future;
|
||||||
|
use std::pin::Pin;
|
||||||
|
use std::task::{Context, Poll};
|
||||||
use std::{fmt, str};
|
use std::{fmt, str};
|
||||||
|
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
|
@ -278,6 +281,18 @@ impl<B: MessageBody> fmt::Debug for Response<B> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Future for Response {
|
||||||
|
type Output = Result<Response, Error>;
|
||||||
|
|
||||||
|
fn poll(mut self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
|
Poll::Ready(Ok(Response {
|
||||||
|
head: self.head.take(),
|
||||||
|
body: self.body.take_body(),
|
||||||
|
error: self.error.take(),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct CookieIter<'a> {
|
pub struct CookieIter<'a> {
|
||||||
iter: header::GetAll<'a>,
|
iter: header::GetAll<'a>,
|
||||||
}
|
}
|
||||||
|
@ -741,6 +756,14 @@ impl<'a> From<&'a ResponseHead> for ResponseBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Future for ResponseBuilder {
|
||||||
|
type Output = Result<Response, Error>;
|
||||||
|
|
||||||
|
fn poll(mut self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
|
Poll::Ready(Ok(self.finish()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl fmt::Debug for ResponseBuilder {
|
impl fmt::Debug for ResponseBuilder {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let head = self.head.as_ref().unwrap();
|
let head = self.head.as_ref().unwrap();
|
||||||
|
|
Loading…
Reference in New Issue