1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2025-01-02 05:18:44 +00:00

move encoding to server

This commit is contained in:
Nikolay Kim 2018-01-11 18:41:33 -08:00
parent 8a058efb4e
commit ac89880c0a
8 changed files with 25 additions and 26 deletions

View file

@ -16,7 +16,7 @@ use cookie::Cookie;
use body::Body;
use error::Error;
use handler::Responder;
use encoding::ContentEncoding;
use headers::ContentEncoding;
use httprequest::HttpRequest;
/// Represents various types of connection

View file

@ -93,7 +93,6 @@ mod application;
mod body;
mod context;
mod helpers;
mod encoding;
mod httprequest;
mod httpresponse;
mod info;
@ -141,12 +140,25 @@ pub use openssl::pkcs12::Pkcs12;
pub mod headers {
//! Headers implementation
pub use encoding::ContentEncoding;
pub use httpresponse::ConnectionType;
pub use cookie::Cookie;
pub use cookie::CookieBuilder;
pub use cookie::{Cookie, CookieBuilder};
pub use http_range::HttpRange;
/// Represents supported types of content encodings
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum ContentEncoding {
/// Automatically select encoding based on encoding negotiation
Auto,
/// A format using the Brotli algorithm
Br,
/// A format using the zlib structure with deflate algorithm
Deflate,
/// Gzip algorithm
Gzip,
/// Indicates the identity function (i.e. no compression, nor modification)
Identity,
}
}
pub mod dev {

View file

@ -12,6 +12,7 @@ use flate2::write::{GzDecoder, GzEncoder, DeflateDecoder, DeflateEncoder};
use brotli2::write::{BrotliDecoder, BrotliEncoder};
use bytes::{Bytes, BytesMut, BufMut, Writer};
use headers::ContentEncoding;
use body::{Body, Binary};
use error::PayloadError;
use helpers::SharedBytes;
@ -19,21 +20,6 @@ use httprequest::HttpMessage;
use httpresponse::HttpResponse;
use payload::{PayloadSender, PayloadWriter};
/// Represents supported types of content encodings
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum ContentEncoding {
/// Automatically select encoding based on encoding negotiation
Auto,
/// A format using the Brotli algorithm
Br,
/// A format using the zlib structure with deflate algorithm
Deflate,
/// Gzip algorithm
Gzip,
/// Indicates the identity function (i.e. no compression, nor modification)
Identity,
}
impl ContentEncoding {
#[inline]

View file

@ -13,7 +13,6 @@ use futures::{Future, Poll, Async};
use tokio_core::reactor::Timeout;
use pipeline::Pipeline;
use encoding::PayloadType;
use httpcodes::HTTPNotFound;
use httprequest::HttpRequest;
use error::{ParseError, PayloadError, ResponseError};
@ -21,6 +20,7 @@ use payload::{Payload, PayloadWriter, DEFAULT_BUFFER_SIZE};
use super::Writer;
use super::h1writer::H1Writer;
use super::encoding::PayloadType;
use super::settings::WorkerSettings;
use super::{HttpHandler, HttpHandlerTask, IoStream};

View file

@ -8,10 +8,10 @@ use http::header::{HeaderValue, CONNECTION, DATE};
use helpers;
use body::Body;
use helpers::SharedBytes;
use encoding::PayloadEncoder;
use httprequest::HttpMessage;
use httpresponse::HttpResponse;
use server::{Writer, WriterState, MAX_WRITE_BUFFER_SIZE};
use super::{Writer, WriterState, MAX_WRITE_BUFFER_SIZE};
use super::encoding::PayloadEncoder;
const AVERAGE_HEADER_SIZE: usize = 30; // totally scientific

View file

@ -16,12 +16,12 @@ use tokio_core::reactor::Timeout;
use pipeline::Pipeline;
use error::PayloadError;
use encoding::PayloadType;
use httpcodes::HTTPNotFound;
use httprequest::HttpRequest;
use payload::{Payload, PayloadWriter};
use super::h2writer::H2Writer;
use super::encoding::PayloadType;
use super::settings::WorkerSettings;
use super::{HttpHandler, HttpHandlerTask};

View file

@ -9,10 +9,10 @@ use http::header::{HeaderValue, CONNECTION, TRANSFER_ENCODING, DATE, CONTENT_LEN
use helpers;
use body::Body;
use helpers::SharedBytes;
use encoding::PayloadEncoder;
use httprequest::HttpMessage;
use httpresponse::HttpResponse;
use server::{Writer, WriterState, MAX_WRITE_BUFFER_SIZE};
use super::encoding::PayloadEncoder;
use super::{Writer, WriterState, MAX_WRITE_BUFFER_SIZE};
const CHUNK_SIZE: usize = 16_384;

View file

@ -8,6 +8,7 @@ use tokio_io::{AsyncRead, AsyncWrite};
mod srv;
mod worker;
mod channel;
mod encoding;
mod h1;
mod h2;
mod h1writer;