1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-11-20 08:31:09 +00:00

rename module

This commit is contained in:
Nikolay Kim 2017-12-13 22:54:52 -08:00
parent 9d0a64ac98
commit 4529efa948
6 changed files with 16 additions and 16 deletions

View file

@ -13,7 +13,7 @@ use flate2::write::{GzEncoder, DeflateDecoder, DeflateEncoder};
use brotli2::write::{BrotliDecoder, BrotliEncoder}; use brotli2::write::{BrotliDecoder, BrotliEncoder};
use bytes::{Bytes, BytesMut, BufMut, Writer}; use bytes::{Bytes, BytesMut, BufMut, Writer};
use utils; use helpers;
use body::{Body, Binary}; use body::{Body, Binary};
use error::PayloadError; use error::PayloadError;
use httprequest::HttpMessage; use httprequest::HttpMessage;
@ -411,13 +411,13 @@ impl PayloadEncoder {
let b = enc.get_mut().take(); let b = enc.get_mut().take();
resp.headers_mut().insert( resp.headers_mut().insert(
CONTENT_LENGTH, utils::convert_into_header(b.len())); CONTENT_LENGTH, helpers::convert_into_header(b.len()));
*bytes = Binary::from(b); *bytes = Binary::from(b);
encoding = ContentEncoding::Identity; encoding = ContentEncoding::Identity;
TransferEncoding::eof() TransferEncoding::eof()
} else { } else {
resp.headers_mut().insert( resp.headers_mut().insert(
CONTENT_LENGTH, utils::convert_into_header(bytes.len())); CONTENT_LENGTH, helpers::convert_into_header(bytes.len()));
TransferEncoding::eof() TransferEncoding::eof()
} }
} }

View file

@ -4,7 +4,7 @@ use tokio_io::AsyncWrite;
use http::Version; use http::Version;
use http::header::{HeaderValue, CONNECTION, CONTENT_TYPE, DATE}; use http::header::{HeaderValue, CONNECTION, CONTENT_TYPE, DATE};
use utils; use helpers;
use body::Body; use body::Body;
use encoding::PayloadEncoder; use encoding::PayloadEncoder;
use httprequest::HttpMessage; 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_10 => buffer.extend_from_slice(b"HTTP/1.0 "),
Version::HTTP_09 => buffer.extend_from_slice(b"HTTP/0.9 "), 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(b" ");
buffer.extend_from_slice(msg.reason().as_bytes()); buffer.extend_from_slice(msg.reason().as_bytes());
buffer.extend_from_slice(b"\r\n"); 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"); 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) { 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: "); buffer.extend_from_slice(b"Date: ");
utils::extend(&mut buffer); helpers::date(&mut buffer);
buffer.extend_from_slice(b"\r\n"); buffer.extend_from_slice(b"\r\n");
} }

View file

@ -6,7 +6,7 @@ use http2::server::Respond;
use http::{Version, HttpTryFrom, Response}; use http::{Version, HttpTryFrom, Response};
use http::header::{HeaderValue, CONNECTION, CONTENT_TYPE, TRANSFER_ENCODING, DATE}; use http::header::{HeaderValue, CONNECTION, CONTENT_TYPE, TRANSFER_ENCODING, DATE};
use utils; use helpers;
use body::Body; use body::Body;
use encoding::PayloadEncoder; use encoding::PayloadEncoder;
use httprequest::HttpMessage; use httprequest::HttpMessage;
@ -124,10 +124,10 @@ impl Writer for H2Writer {
msg.headers_mut().remove(CONNECTION); msg.headers_mut().remove(CONNECTION);
msg.headers_mut().remove(TRANSFER_ENCODING); 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) { if !msg.headers().contains_key(DATE) {
let mut bytes = BytesMut::with_capacity(29); 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()); msg.headers_mut().insert(DATE, HeaderValue::try_from(&bytes[..]).unwrap());
} }

View file

@ -8,7 +8,7 @@ use http::header::HeaderValue;
// "Sun, 06 Nov 1994 08:49:37 GMT".len() // "Sun, 06 Nov 1994 08:49:37 GMT".len()
pub const DATE_VALUE_LENGTH: usize = 29; pub const DATE_VALUE_LENGTH: usize = 29;
pub fn extend(dst: &mut BytesMut) { pub fn date(dst: &mut BytesMut) {
CACHED.with(|cache| { CACHED.with(|cache| {
dst.extend_from_slice(cache.borrow().buffer()); dst.extend_from_slice(cache.borrow().buffer());
}) })

View file

@ -55,7 +55,7 @@ extern crate tokio_openssl;
mod application; mod application;
mod body; mod body;
mod context; mod context;
mod utils; mod helpers;
mod encoding; mod encoding;
mod httprequest; mod httprequest;
mod httpresponse; mod httpresponse;

View file

@ -28,7 +28,7 @@ use openssl::pkcs12::ParsedPkcs12;
#[cfg(feature="alpn")] #[cfg(feature="alpn")]
use tokio_openssl::{SslStream, SslAcceptorExt}; use tokio_openssl::{SslStream, SslAcceptorExt};
use utils; use helpers;
use channel::{HttpChannel, HttpHandler, IntoHttpHandler}; use channel::{HttpChannel, HttpHandler, IntoHttpHandler};
/// Various server settings /// 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> { impl<T: 'static, A: 'static, H, U: 'static> HttpServer<T, A, H, U> {
fn update_time(&self, ctx: &mut Context<Self>) { 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)); 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>) { 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)); ctx.run_later(Duration::new(1, 0), |slf, ctx| slf.update_time(ctx));
} }
} }