mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
rename module
This commit is contained in:
parent
9d0a64ac98
commit
4529efa948
@ -13,7 +13,7 @@ use flate2::write::{GzEncoder, DeflateDecoder, DeflateEncoder};
|
||||
use brotli2::write::{BrotliDecoder, BrotliEncoder};
|
||||
use bytes::{Bytes, BytesMut, BufMut, Writer};
|
||||
|
||||
use utils;
|
||||
use helpers;
|
||||
use body::{Body, Binary};
|
||||
use error::PayloadError;
|
||||
use httprequest::HttpMessage;
|
||||
@ -411,13 +411,13 @@ impl PayloadEncoder {
|
||||
let b = enc.get_mut().take();
|
||||
|
||||
resp.headers_mut().insert(
|
||||
CONTENT_LENGTH, utils::convert_into_header(b.len()));
|
||||
CONTENT_LENGTH, helpers::convert_into_header(b.len()));
|
||||
*bytes = Binary::from(b);
|
||||
encoding = ContentEncoding::Identity;
|
||||
TransferEncoding::eof()
|
||||
} else {
|
||||
resp.headers_mut().insert(
|
||||
CONTENT_LENGTH, utils::convert_into_header(bytes.len()));
|
||||
CONTENT_LENGTH, helpers::convert_into_header(bytes.len()));
|
||||
TransferEncoding::eof()
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use tokio_io::AsyncWrite;
|
||||
use http::Version;
|
||||
use http::header::{HeaderValue, CONNECTION, CONTENT_TYPE, DATE};
|
||||
|
||||
use utils;
|
||||
use helpers;
|
||||
use body::Body;
|
||||
use encoding::PayloadEncoder;
|
||||
use httprequest::HttpMessage;
|
||||
@ -159,7 +159,7 @@ impl<T: AsyncWrite> Writer for H1Writer<T> {
|
||||
Version::HTTP_10 => buffer.extend_from_slice(b"HTTP/1.0 "),
|
||||
Version::HTTP_09 => buffer.extend_from_slice(b"HTTP/0.9 "),
|
||||
}
|
||||
utils::convert_u16(msg.status().as_u16(), &mut buffer);
|
||||
helpers::convert_u16(msg.status().as_u16(), &mut buffer);
|
||||
buffer.extend_from_slice(b" ");
|
||||
buffer.extend_from_slice(msg.reason().as_bytes());
|
||||
buffer.extend_from_slice(b"\r\n");
|
||||
@ -172,11 +172,11 @@ impl<T: AsyncWrite> Writer for H1Writer<T> {
|
||||
buffer.extend_from_slice(b"\r\n");
|
||||
}
|
||||
|
||||
// using utils::date is quite a lot faster
|
||||
// using helpers::date is quite a lot faster
|
||||
if !msg.headers().contains_key(DATE) {
|
||||
buffer.reserve(utils::DATE_VALUE_LENGTH + 8);
|
||||
buffer.reserve(helpers::DATE_VALUE_LENGTH + 8);
|
||||
buffer.extend_from_slice(b"Date: ");
|
||||
utils::extend(&mut buffer);
|
||||
helpers::date(&mut buffer);
|
||||
buffer.extend_from_slice(b"\r\n");
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ use http2::server::Respond;
|
||||
use http::{Version, HttpTryFrom, Response};
|
||||
use http::header::{HeaderValue, CONNECTION, CONTENT_TYPE, TRANSFER_ENCODING, DATE};
|
||||
|
||||
use utils;
|
||||
use helpers;
|
||||
use body::Body;
|
||||
use encoding::PayloadEncoder;
|
||||
use httprequest::HttpMessage;
|
||||
@ -124,10 +124,10 @@ impl Writer for H2Writer {
|
||||
msg.headers_mut().remove(CONNECTION);
|
||||
msg.headers_mut().remove(TRANSFER_ENCODING);
|
||||
|
||||
// using utils::date is quite a lot faster
|
||||
// using helpers::date is quite a lot faster
|
||||
if !msg.headers().contains_key(DATE) {
|
||||
let mut bytes = BytesMut::with_capacity(29);
|
||||
utils::extend(&mut bytes);
|
||||
helpers::date(&mut bytes);
|
||||
msg.headers_mut().insert(DATE, HeaderValue::try_from(&bytes[..]).unwrap());
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ use http::header::HeaderValue;
|
||||
// "Sun, 06 Nov 1994 08:49:37 GMT".len()
|
||||
pub const DATE_VALUE_LENGTH: usize = 29;
|
||||
|
||||
pub fn extend(dst: &mut BytesMut) {
|
||||
pub fn date(dst: &mut BytesMut) {
|
||||
CACHED.with(|cache| {
|
||||
dst.extend_from_slice(cache.borrow().buffer());
|
||||
})
|
@ -55,7 +55,7 @@ extern crate tokio_openssl;
|
||||
mod application;
|
||||
mod body;
|
||||
mod context;
|
||||
mod utils;
|
||||
mod helpers;
|
||||
mod encoding;
|
||||
mod httprequest;
|
||||
mod httpresponse;
|
||||
|
@ -28,7 +28,7 @@ use openssl::pkcs12::ParsedPkcs12;
|
||||
#[cfg(feature="alpn")]
|
||||
use tokio_openssl::{SslStream, SslAcceptorExt};
|
||||
|
||||
use utils;
|
||||
use helpers;
|
||||
use channel::{HttpChannel, HttpHandler, IntoHttpHandler};
|
||||
|
||||
/// Various server settings
|
||||
@ -109,7 +109,7 @@ impl<T: 'static, A: 'static, H, U: 'static> Actor for HttpServer<T, A, H, U> {
|
||||
|
||||
impl<T: 'static, A: 'static, H, U: 'static> HttpServer<T, A, H, U> {
|
||||
fn update_time(&self, ctx: &mut Context<Self>) {
|
||||
utils::update_date();
|
||||
helpers::update_date();
|
||||
ctx.run_later(Duration::new(1, 0), |slf, ctx| slf.update_time(ctx));
|
||||
}
|
||||
}
|
||||
@ -434,7 +434,7 @@ impl<H: 'static> Worker<H> {
|
||||
}
|
||||
|
||||
fn update_time(&self, ctx: &mut Context<Self>) {
|
||||
utils::update_date();
|
||||
helpers::update_date();
|
||||
ctx.run_later(Duration::new(1, 0), |slf, ctx| slf.update_time(ctx));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user