mirror of
https://github.com/actix/actix-web.git
synced 2025-01-06 15:28:54 +00:00
move encoding to server
This commit is contained in:
parent
8a058efb4e
commit
ac89880c0a
8 changed files with 25 additions and 26 deletions
|
@ -16,7 +16,7 @@ use cookie::Cookie;
|
||||||
use body::Body;
|
use body::Body;
|
||||||
use error::Error;
|
use error::Error;
|
||||||
use handler::Responder;
|
use handler::Responder;
|
||||||
use encoding::ContentEncoding;
|
use headers::ContentEncoding;
|
||||||
use httprequest::HttpRequest;
|
use httprequest::HttpRequest;
|
||||||
|
|
||||||
/// Represents various types of connection
|
/// Represents various types of connection
|
||||||
|
|
20
src/lib.rs
20
src/lib.rs
|
@ -93,7 +93,6 @@ mod application;
|
||||||
mod body;
|
mod body;
|
||||||
mod context;
|
mod context;
|
||||||
mod helpers;
|
mod helpers;
|
||||||
mod encoding;
|
|
||||||
mod httprequest;
|
mod httprequest;
|
||||||
mod httpresponse;
|
mod httpresponse;
|
||||||
mod info;
|
mod info;
|
||||||
|
@ -141,12 +140,25 @@ pub use openssl::pkcs12::Pkcs12;
|
||||||
pub mod headers {
|
pub mod headers {
|
||||||
//! Headers implementation
|
//! Headers implementation
|
||||||
|
|
||||||
pub use encoding::ContentEncoding;
|
|
||||||
pub use httpresponse::ConnectionType;
|
pub use httpresponse::ConnectionType;
|
||||||
|
|
||||||
pub use cookie::Cookie;
|
pub use cookie::{Cookie, CookieBuilder};
|
||||||
pub use cookie::CookieBuilder;
|
|
||||||
pub use http_range::HttpRange;
|
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 {
|
pub mod dev {
|
||||||
|
|
|
@ -12,6 +12,7 @@ use flate2::write::{GzDecoder, 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 headers::ContentEncoding;
|
||||||
use body::{Body, Binary};
|
use body::{Body, Binary};
|
||||||
use error::PayloadError;
|
use error::PayloadError;
|
||||||
use helpers::SharedBytes;
|
use helpers::SharedBytes;
|
||||||
|
@ -19,21 +20,6 @@ use httprequest::HttpMessage;
|
||||||
use httpresponse::HttpResponse;
|
use httpresponse::HttpResponse;
|
||||||
use payload::{PayloadSender, PayloadWriter};
|
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 {
|
impl ContentEncoding {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
|
@ -13,7 +13,6 @@ use futures::{Future, Poll, Async};
|
||||||
use tokio_core::reactor::Timeout;
|
use tokio_core::reactor::Timeout;
|
||||||
|
|
||||||
use pipeline::Pipeline;
|
use pipeline::Pipeline;
|
||||||
use encoding::PayloadType;
|
|
||||||
use httpcodes::HTTPNotFound;
|
use httpcodes::HTTPNotFound;
|
||||||
use httprequest::HttpRequest;
|
use httprequest::HttpRequest;
|
||||||
use error::{ParseError, PayloadError, ResponseError};
|
use error::{ParseError, PayloadError, ResponseError};
|
||||||
|
@ -21,6 +20,7 @@ use payload::{Payload, PayloadWriter, DEFAULT_BUFFER_SIZE};
|
||||||
|
|
||||||
use super::Writer;
|
use super::Writer;
|
||||||
use super::h1writer::H1Writer;
|
use super::h1writer::H1Writer;
|
||||||
|
use super::encoding::PayloadType;
|
||||||
use super::settings::WorkerSettings;
|
use super::settings::WorkerSettings;
|
||||||
use super::{HttpHandler, HttpHandlerTask, IoStream};
|
use super::{HttpHandler, HttpHandlerTask, IoStream};
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@ use http::header::{HeaderValue, CONNECTION, DATE};
|
||||||
use helpers;
|
use helpers;
|
||||||
use body::Body;
|
use body::Body;
|
||||||
use helpers::SharedBytes;
|
use helpers::SharedBytes;
|
||||||
use encoding::PayloadEncoder;
|
|
||||||
use httprequest::HttpMessage;
|
use httprequest::HttpMessage;
|
||||||
use httpresponse::HttpResponse;
|
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
|
const AVERAGE_HEADER_SIZE: usize = 30; // totally scientific
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,12 @@ use tokio_core::reactor::Timeout;
|
||||||
|
|
||||||
use pipeline::Pipeline;
|
use pipeline::Pipeline;
|
||||||
use error::PayloadError;
|
use error::PayloadError;
|
||||||
use encoding::PayloadType;
|
|
||||||
use httpcodes::HTTPNotFound;
|
use httpcodes::HTTPNotFound;
|
||||||
use httprequest::HttpRequest;
|
use httprequest::HttpRequest;
|
||||||
use payload::{Payload, PayloadWriter};
|
use payload::{Payload, PayloadWriter};
|
||||||
|
|
||||||
use super::h2writer::H2Writer;
|
use super::h2writer::H2Writer;
|
||||||
|
use super::encoding::PayloadType;
|
||||||
use super::settings::WorkerSettings;
|
use super::settings::WorkerSettings;
|
||||||
use super::{HttpHandler, HttpHandlerTask};
|
use super::{HttpHandler, HttpHandlerTask};
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,10 @@ use http::header::{HeaderValue, CONNECTION, TRANSFER_ENCODING, DATE, CONTENT_LEN
|
||||||
use helpers;
|
use helpers;
|
||||||
use body::Body;
|
use body::Body;
|
||||||
use helpers::SharedBytes;
|
use helpers::SharedBytes;
|
||||||
use encoding::PayloadEncoder;
|
|
||||||
use httprequest::HttpMessage;
|
use httprequest::HttpMessage;
|
||||||
use httpresponse::HttpResponse;
|
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;
|
const CHUNK_SIZE: usize = 16_384;
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ use tokio_io::{AsyncRead, AsyncWrite};
|
||||||
mod srv;
|
mod srv;
|
||||||
mod worker;
|
mod worker;
|
||||||
mod channel;
|
mod channel;
|
||||||
|
mod encoding;
|
||||||
mod h1;
|
mod h1;
|
||||||
mod h2;
|
mod h2;
|
||||||
mod h1writer;
|
mod h1writer;
|
||||||
|
|
Loading…
Reference in a new issue