mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-25 06:39:22 +02:00
compile with default-features off
This commit is contained in:
@ -22,7 +22,7 @@ path = "src/lib.rs"
|
||||
features = ["openssl", "rustls", "compress"]
|
||||
|
||||
[features]
|
||||
default = ["compress"]
|
||||
default = [] #"compress"]
|
||||
|
||||
# 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"] }
|
||||
|
||||
[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-http = { 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 bytes::Bytes;
|
||||
use derive_more::From;
|
||||
use futures_core::{ready, Future, Stream};
|
||||
use futures_core::{Future, Stream};
|
||||
use serde::Serialize;
|
||||
use serde_json;
|
||||
|
||||
use actix_http::body::{Body, BodyStream};
|
||||
use actix_http::encoding::Decoder;
|
||||
use actix_http::http::header::{self, ContentEncoding, IntoHeaderValue};
|
||||
use actix_http::http::header::{self, IntoHeaderValue};
|
||||
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::response::ClientResponse;
|
||||
@ -67,6 +73,7 @@ impl SendClientRequest {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "compress")]
|
||||
impl Future for SendClientRequest {
|
||||
type Output =
|
||||
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| {
|
||||
if *response_decompress {
|
||||
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 {
|
||||
fn from(e: SendRequestError) -> Self {
|
||||
SendClientRequest::Err(Some(e))
|
||||
|
Reference in New Issue
Block a user