1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-19 04:15:38 +02:00

flush stream on drain

This commit is contained in:
Nikolay Kim
2018-01-11 16:22:27 -08:00
parent 0a41ecd01d
commit 0707dfe5bb
6 changed files with 91 additions and 9 deletions

View File

@@ -1,11 +1,12 @@
//! Pieces pertaining to the HTTP response.
use std::{mem, str, fmt};
use std::io::Write;
use std::cell::RefCell;
use std::convert::Into;
use std::collections::VecDeque;
use cookie::CookieJar;
use bytes::{Bytes, BytesMut};
use bytes::{Bytes, BytesMut, BufMut};
use http::{StatusCode, Version, HeaderMap, HttpTryFrom, Error as HttpError};
use http::header::{self, HeaderName, HeaderValue};
use serde_json;
@@ -347,6 +348,14 @@ impl HttpResponseBuilder {
self
}
/// Set content length
#[inline]
pub fn content_length(&mut self, len: u64) -> &mut Self {
let mut wrt = BytesMut::new().writer();
let _ = write!(wrt, "{}", len);
self.header(header::CONTENT_LENGTH, wrt.get_mut().take().freeze())
}
/// Set a cookie
///
/// ```rust