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

rollback changes to actix-web, awc and test-server for now

This commit is contained in:
Maksym Vorobiov
2020-01-31 10:29:10 +02:00
committed by Yuki Okushi
parent 62aba424e2
commit 09a391a3ca
6 changed files with 27 additions and 30 deletions

View File

@ -238,24 +238,19 @@ where
}
}
use pin_project::{pin_project, pinned_drop};
#[pin_project(PinnedDrop)]
pub struct StreamLog<B> {
#[pin]
body: ResponseBody<B>,
format: Option<Format>,
size: usize,
time: OffsetDateTime,
}
#[pinned_drop]
impl<B> PinnedDrop for StreamLog<B> {
fn drop(self: Pin<&mut Self>) {
let this = self.project();
if let Some(ref format) = this.format {
impl<B> Drop for StreamLog<B> {
fn drop(&mut self) {
if let Some(ref format) = self.format {
let render = |fmt: &mut Formatter<'_>| {
for unit in &format.0 {
unit.render(fmt, *this.size, *this.time)?;
unit.render(fmt, self.size, self.time)?;
}
Ok(())
};
@ -269,11 +264,10 @@ impl<B: MessageBody> MessageBody for StreamLog<B> {
self.body.size()
}
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Result<Bytes, Error>>> {
let this = self.project();
match this.body.poll_next(cx) {
fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<Result<Bytes, Error>>> {
match self.body.poll_next(cx) {
Poll::Ready(Some(Ok(chunk))) => {
*this.size += chunk.len();
self.size += chunk.len();
Poll::Ready(Some(Ok(chunk)))
}
val => val,