1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-25 14:49:20 +02:00

update tests to async handlers

This commit is contained in:
Nikolay Kim
2019-11-22 11:49:35 +06:00
parent e668acc596
commit 57981ca04a
9 changed files with 111 additions and 79 deletions

View File

@ -388,6 +388,12 @@ impl BoxedResponseHead {
pub fn new(status: StatusCode) -> Self {
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 {
@ -406,7 +412,9 @@ impl std::ops::DerefMut for BoxedResponseHead {
impl Drop for BoxedResponseHead {
fn drop(&mut self) {
RESPONSE_POOL.with(|p| p.release(self.head.take().unwrap()))
if let Some(head) = self.head.take() {
RESPONSE_POOL.with(move |p| p.release(head))
}
}
}

View File

@ -288,10 +288,7 @@ impl Future for Response {
fn poll(mut self: Pin<&mut Self>, _: &mut Context) -> Poll<Self::Output> {
Poll::Ready(Ok(Response {
head: std::mem::replace(
&mut self.head,
BoxedResponseHead::new(StatusCode::OK),
),
head: self.head.take(),
body: self.body.take_body(),
error: self.error.take(),
}))