mirror of
https://github.com/fafhrd91/actix-web
synced 2025-02-17 10:13:30 +01:00
compile with default-features off
This commit is contained in:
parent
e8e0f98f96
commit
cb705317b8
22
Cargo.toml
22
Cargo.toml
@ -106,14 +106,14 @@ lto = true
|
|||||||
opt-level = 3
|
opt-level = 3
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
|
|
||||||
# [patch.crates-io]
|
[patch.crates-io]
|
||||||
# actix-web = { path = "." }
|
actix-web = { path = "." }
|
||||||
# actix-http = { path = "actix-http" }
|
actix-http = { path = "actix-http" }
|
||||||
# actix-http-test = { path = "test-server" }
|
actix-http-test = { path = "test-server" }
|
||||||
# actix-web-codegen = { path = "actix-web-codegen" }
|
actix-web-codegen = { path = "actix-web-codegen" }
|
||||||
# actix-cors = { path = "actix-cors" }
|
actix-cors = { path = "actix-cors" }
|
||||||
# actix-identity = { path = "actix-identity" }
|
actix-identity = { path = "actix-identity" }
|
||||||
# actix-session = { path = "actix-session" }
|
actix-session = { path = "actix-session" }
|
||||||
# actix-files = { path = "actix-files" }
|
actix-files = { path = "actix-files" }
|
||||||
# actix-multipart = { path = "actix-multipart" }
|
actix-multipart = { path = "actix-multipart" }
|
||||||
# awc = { path = "awc" }
|
awc = { path = "awc" }
|
||||||
|
@ -42,7 +42,7 @@ secure-cookies = ["ring"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
actix-service = "1.0.0"
|
actix-service = "1.0.0"
|
||||||
actix-codec = "0.2.0"
|
actix-codec = "0.2.0"
|
||||||
actix-connect = "1.0.0"
|
actix-connect = "1.0.1"
|
||||||
actix-utils = "1.0.3"
|
actix-utils = "1.0.3"
|
||||||
actix-rt = "1.0.0"
|
actix-rt = "1.0.0"
|
||||||
actix-threadpool = "0.3.1"
|
actix-threadpool = "0.3.1"
|
||||||
|
@ -22,7 +22,7 @@ path = "src/lib.rs"
|
|||||||
features = ["openssl", "rustls", "compress"]
|
features = ["openssl", "rustls", "compress"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["compress"]
|
default = [] #"compress"]
|
||||||
|
|
||||||
# openssl
|
# openssl
|
||||||
openssl = ["open-ssl", "actix-http/openssl"]
|
openssl = ["open-ssl", "actix-http/openssl"]
|
||||||
@ -54,7 +54,7 @@ open-ssl = { version="0.10", package="openssl", optional = true }
|
|||||||
rust-tls = { version = "0.16.0", package="rustls", optional = true, features = ["dangerous_configuration"] }
|
rust-tls = { version = "0.16.0", package="rustls", optional = true, features = ["dangerous_configuration"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-connect = { version = "1.0.0", features=["openssl"] }
|
actix-connect = { version = "1.0.1", features=["openssl"] }
|
||||||
actix-web = { version = "2.0.0-alpha.5", features=["openssl"] }
|
actix-web = { version = "2.0.0-alpha.5", features=["openssl"] }
|
||||||
actix-http = { version = "1.0.0", features=["openssl"] }
|
actix-http = { version = "1.0.0", features=["openssl"] }
|
||||||
actix-http-test = { version = "1.0.0", features=["openssl"] }
|
actix-http-test = { version = "1.0.0", features=["openssl"] }
|
||||||
|
@ -7,15 +7,21 @@ use std::time::Duration;
|
|||||||
use actix_rt::time::{delay_for, Delay};
|
use actix_rt::time::{delay_for, Delay};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use derive_more::From;
|
use derive_more::From;
|
||||||
use futures_core::{ready, Future, Stream};
|
use futures_core::{Future, Stream};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
use actix_http::body::{Body, BodyStream};
|
use actix_http::body::{Body, BodyStream};
|
||||||
use actix_http::encoding::Decoder;
|
use actix_http::http::header::{self, IntoHeaderValue};
|
||||||
use actix_http::http::header::{self, ContentEncoding, IntoHeaderValue};
|
|
||||||
use actix_http::http::{Error as HttpError, HeaderMap, HeaderName};
|
use actix_http::http::{Error as HttpError, HeaderMap, HeaderName};
|
||||||
use actix_http::{Error, Payload, PayloadStream, RequestHead};
|
use actix_http::{Error, RequestHead};
|
||||||
|
|
||||||
|
#[cfg(feature = "compress")]
|
||||||
|
use actix_http::encoding::Decoder;
|
||||||
|
#[cfg(feature = "compress")]
|
||||||
|
use actix_http::http::header::ContentEncoding;
|
||||||
|
#[cfg(feature = "compress")]
|
||||||
|
use actix_http::{Payload, PayloadStream};
|
||||||
|
|
||||||
use crate::error::{FreezeRequestError, InvalidUrl, SendRequestError};
|
use crate::error::{FreezeRequestError, InvalidUrl, SendRequestError};
|
||||||
use crate::response::ClientResponse;
|
use crate::response::ClientResponse;
|
||||||
@ -67,6 +73,7 @@ impl SendClientRequest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "compress")]
|
||||||
impl Future for SendClientRequest {
|
impl Future for SendClientRequest {
|
||||||
type Output =
|
type Output =
|
||||||
Result<ClientResponse<Decoder<Payload<PayloadStream>>>, SendRequestError>;
|
Result<ClientResponse<Decoder<Payload<PayloadStream>>>, SendRequestError>;
|
||||||
@ -83,7 +90,7 @@ impl Future for SendClientRequest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = ready!(Pin::new(send).poll(cx)).map(|res| {
|
let res = futures_core::ready!(Pin::new(send).poll(cx)).map(|res| {
|
||||||
res.map_body(|head, payload| {
|
res.map_body(|head, payload| {
|
||||||
if *response_decompress {
|
if *response_decompress {
|
||||||
Payload::Stream(Decoder::from_headers(
|
Payload::Stream(Decoder::from_headers(
|
||||||
@ -109,6 +116,30 @@ impl Future for SendClientRequest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "compress"))]
|
||||||
|
impl Future for SendClientRequest {
|
||||||
|
type Output = Result<ClientResponse, SendRequestError>;
|
||||||
|
|
||||||
|
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
|
let this = self.get_mut();
|
||||||
|
match this {
|
||||||
|
SendClientRequest::Fut(send, delay, _) => {
|
||||||
|
if delay.is_some() {
|
||||||
|
match Pin::new(delay.as_mut().unwrap()).poll(cx) {
|
||||||
|
Poll::Pending => (),
|
||||||
|
_ => return Poll::Ready(Err(SendRequestError::Timeout)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Pin::new(send).poll(cx)
|
||||||
|
}
|
||||||
|
SendClientRequest::Err(ref mut e) => match e.take() {
|
||||||
|
Some(e) => Poll::Ready(Err(e)),
|
||||||
|
None => panic!("Attempting to call completed future"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<SendRequestError> for SendClientRequest {
|
impl From<SendRequestError> for SendClientRequest {
|
||||||
fn from(e: SendRequestError) -> Self {
|
fn from(e: SendRequestError) -> Self {
|
||||||
SendClientRequest::Err(Some(e))
|
SendClientRequest::Err(Some(e))
|
||||||
|
@ -141,6 +141,7 @@ pub mod dev {
|
|||||||
pub use crate::types::readlines::Readlines;
|
pub use crate::types::readlines::Readlines;
|
||||||
|
|
||||||
pub use actix_http::body::{Body, BodySize, MessageBody, ResponseBody, SizedStream};
|
pub use actix_http::body::{Body, BodySize, MessageBody, ResponseBody, SizedStream};
|
||||||
|
#[cfg(feature = "compress")]
|
||||||
pub use actix_http::encoding::Decoder as Decompress;
|
pub use actix_http::encoding::Decoder as Decompress;
|
||||||
pub use actix_http::ResponseBuilder as HttpResponseBuilder;
|
pub use actix_http::ResponseBuilder as HttpResponseBuilder;
|
||||||
pub use actix_http::{
|
pub use actix_http::{
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
//! Middlewares
|
//! Middlewares
|
||||||
|
|
||||||
|
#[cfg(feature = "compress")]
|
||||||
mod compress;
|
mod compress;
|
||||||
|
#[cfg(feature = "compress")]
|
||||||
pub use self::compress::{BodyEncoding, Compress};
|
pub use self::compress::{BodyEncoding, Compress};
|
||||||
|
|
||||||
mod condition;
|
mod condition;
|
||||||
|
@ -14,6 +14,7 @@ use futures::StreamExt;
|
|||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
#[cfg(feature = "compress")]
|
||||||
use crate::dev::Decompress;
|
use crate::dev::Decompress;
|
||||||
use crate::error::UrlencodedError;
|
use crate::error::UrlencodedError;
|
||||||
use crate::extract::FromRequest;
|
use crate::extract::FromRequest;
|
||||||
@ -240,7 +241,10 @@ impl Default for FormConfig {
|
|||||||
/// * content-length is greater than 32k
|
/// * content-length is greater than 32k
|
||||||
///
|
///
|
||||||
pub struct UrlEncoded<U> {
|
pub struct UrlEncoded<U> {
|
||||||
|
#[cfg(feature = "compress")]
|
||||||
stream: Option<Decompress<Payload>>,
|
stream: Option<Decompress<Payload>>,
|
||||||
|
#[cfg(not(feature = "compress"))]
|
||||||
|
stream: Option<Payload>,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
length: Option<usize>,
|
length: Option<usize>,
|
||||||
encoding: &'static Encoding,
|
encoding: &'static Encoding,
|
||||||
@ -273,7 +277,11 @@ impl<U> UrlEncoded<U> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "compress")]
|
||||||
let payload = Decompress::from_headers(payload.take(), req.headers());
|
let payload = Decompress::from_headers(payload.take(), req.headers());
|
||||||
|
#[cfg(not(feature = "compress"))]
|
||||||
|
let payload = payload.take();
|
||||||
|
|
||||||
UrlEncoded {
|
UrlEncoded {
|
||||||
encoding,
|
encoding,
|
||||||
stream: Some(payload),
|
stream: Some(payload),
|
||||||
|
@ -16,6 +16,7 @@ use serde_json;
|
|||||||
use actix_http::http::{header::CONTENT_LENGTH, StatusCode};
|
use actix_http::http::{header::CONTENT_LENGTH, StatusCode};
|
||||||
use actix_http::{HttpMessage, Payload, Response};
|
use actix_http::{HttpMessage, Payload, Response};
|
||||||
|
|
||||||
|
#[cfg(feature = "compress")]
|
||||||
use crate::dev::Decompress;
|
use crate::dev::Decompress;
|
||||||
use crate::error::{Error, JsonPayloadError};
|
use crate::error::{Error, JsonPayloadError};
|
||||||
use crate::extract::FromRequest;
|
use crate::extract::FromRequest;
|
||||||
@ -293,7 +294,10 @@ impl Default for JsonConfig {
|
|||||||
pub struct JsonBody<U> {
|
pub struct JsonBody<U> {
|
||||||
limit: usize,
|
limit: usize,
|
||||||
length: Option<usize>,
|
length: Option<usize>,
|
||||||
|
#[cfg(feature = "compress")]
|
||||||
stream: Option<Decompress<Payload>>,
|
stream: Option<Decompress<Payload>>,
|
||||||
|
#[cfg(not(feature = "compress"))]
|
||||||
|
stream: Option<Payload>,
|
||||||
err: Option<JsonPayloadError>,
|
err: Option<JsonPayloadError>,
|
||||||
fut: Option<LocalBoxFuture<'static, Result<U, JsonPayloadError>>>,
|
fut: Option<LocalBoxFuture<'static, Result<U, JsonPayloadError>>>,
|
||||||
}
|
}
|
||||||
@ -332,7 +336,11 @@ where
|
|||||||
.get(&CONTENT_LENGTH)
|
.get(&CONTENT_LENGTH)
|
||||||
.and_then(|l| l.to_str().ok())
|
.and_then(|l| l.to_str().ok())
|
||||||
.and_then(|s| s.parse::<usize>().ok());
|
.and_then(|s| s.parse::<usize>().ok());
|
||||||
|
|
||||||
|
#[cfg(feature = "compress")]
|
||||||
let payload = Decompress::from_headers(payload.take(), req.headers());
|
let payload = Decompress::from_headers(payload.take(), req.headers());
|
||||||
|
#[cfg(not(feature = "compress"))]
|
||||||
|
let payload = payload.take();
|
||||||
|
|
||||||
JsonBody {
|
JsonBody {
|
||||||
limit: 262_144,
|
limit: 262_144,
|
||||||
|
@ -301,7 +301,10 @@ impl Default for PayloadConfig {
|
|||||||
pub struct HttpMessageBody {
|
pub struct HttpMessageBody {
|
||||||
limit: usize,
|
limit: usize,
|
||||||
length: Option<usize>,
|
length: Option<usize>,
|
||||||
|
#[cfg(feature = "compress")]
|
||||||
stream: Option<dev::Decompress<dev::Payload>>,
|
stream: Option<dev::Decompress<dev::Payload>>,
|
||||||
|
#[cfg(not(feature = "compress"))]
|
||||||
|
stream: Option<dev::Payload>,
|
||||||
err: Option<PayloadError>,
|
err: Option<PayloadError>,
|
||||||
fut: Option<LocalBoxFuture<'static, Result<Bytes, PayloadError>>>,
|
fut: Option<LocalBoxFuture<'static, Result<Bytes, PayloadError>>>,
|
||||||
}
|
}
|
||||||
@ -322,8 +325,13 @@ impl HttpMessageBody {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "compress")]
|
||||||
|
let stream = Some(dev::Decompress::from_headers(payload.take(), req.headers()));
|
||||||
|
#[cfg(not(feature = "compress"))]
|
||||||
|
let stream = Some(payload.take());
|
||||||
|
|
||||||
HttpMessageBody {
|
HttpMessageBody {
|
||||||
stream: Some(dev::Decompress::from_headers(payload.take(), req.headers())),
|
stream,
|
||||||
limit: 262_144,
|
limit: 262_144,
|
||||||
length: len,
|
length: len,
|
||||||
fut: None,
|
fut: None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user