fix feature flag

This commit is contained in:
Rob Ede 2021-04-01 21:23:20 +01:00
parent 34d3c7a835
commit 4e59bff1aa
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
8 changed files with 42 additions and 21 deletions

View File

@ -52,10 +52,10 @@ cookies = ["actix-http/cookies"]
secure-cookies = ["actix-http/secure-cookies"]
# openssl
openssl = ["actix-tls/accept", "actix-tls/openssl"]
openssl = ["actix-http/openssl", "actix-tls/accept", "actix-tls/openssl"]
# rustls
rustls = ["actix-tls/accept", "actix-tls/rustls"]
rustls = ["actix-http/rustls", "actix-tls/accept", "actix-tls/rustls"]
[[example]]
name = "basic"
@ -108,7 +108,7 @@ time = { version = "0.2.23", default-features = false, features = ["std"] }
url = "2.1"
[dev-dependencies]
actix-test = "0.0.1"
actix-test = { version = "0.0.1", features = ["openssl", "rustls"] }
awc = { version = "3.0.0-beta.3", features = ["openssl"] }
brotli2 = "0.3.2"

View File

@ -48,7 +48,7 @@ actix-service = "2.0.0-beta.4"
actix-codec = "0.4.0-beta.1"
actix-utils = "3.0.0-beta.4"
actix-rt = "2.2"
actix-tls = "3.0.0-beta.5"
actix-tls = { version = "3.0.0-beta.5", features = ["accept", "connect"] }
ahash = "0.7"
base64 = "0.13"

View File

@ -153,11 +153,14 @@ where
S::InitError: fmt::Debug,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service<Request>>::Future: 'static,
B: MessageBody + 'static,
X: ServiceFactory<Request, Config = (), Response = Request>,
X::Future: 'static,
X::Error: Into<Error>,
X::InitError: fmt::Debug,
U: ServiceFactory<
(Request, Framed<TcpStream, h1::Codec>),
Config = (),
@ -187,11 +190,12 @@ where
#[cfg(feature = "openssl")]
mod openssl {
use super::*;
use actix_service::ServiceFactoryExt;
use actix_tls::accept::openssl::{Acceptor, SslAcceptor, SslError, TlsStream};
use actix_tls::accept::TlsError;
use super::*;
impl<S, B, X, U> HttpService<TlsStream<TcpStream>, S, B, X, U>
where
S: ServiceFactory<Request, Config = ()>,
@ -200,11 +204,14 @@ mod openssl {
S::InitError: fmt::Debug,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service<Request>>::Future: 'static,
B: MessageBody + 'static,
X: ServiceFactory<Request, Config = (), Response = Request>,
X::Future: 'static,
X::Error: Into<Error>,
X::InitError: fmt::Debug,
U: ServiceFactory<
(Request, Framed<TlsStream<TcpStream>, h1::Codec>),
Config = (),
@ -252,11 +259,11 @@ mod openssl {
mod rustls {
use std::io;
use actix_service::ServiceFactoryExt as _;
use actix_tls::accept::rustls::{Acceptor, ServerConfig, Session, TlsStream};
use actix_tls::accept::TlsError;
use super::*;
use actix_service::ServiceFactoryExt;
impl<S, B, X, U> HttpService<TlsStream<TcpStream>, S, B, X, U>
where
@ -266,11 +273,14 @@ mod rustls {
S::InitError: fmt::Debug,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service<Request>>::Future: 'static,
B: MessageBody + 'static,
X: ServiceFactory<Request, Config = (), Response = Request>,
X::Future: 'static,
X::Error: Into<Error>,
X::InitError: fmt::Debug,
U: ServiceFactory<
(Request, Framed<TlsStream<TcpStream>, h1::Codec>),
Config = (),
@ -280,7 +290,7 @@ mod rustls {
U::Error: fmt::Display + Into<Error>,
U::InitError: fmt::Debug,
{
/// Create openssl based service
/// Create rustls based service
pub fn rustls(
self,
mut config: ServerConfig,
@ -321,17 +331,21 @@ impl<T, S, B, X, U> ServiceFactory<(T, Protocol, Option<net::SocketAddr>)>
for HttpService<T, S, B, X, U>
where
T: AsyncRead + AsyncWrite + Unpin + 'static,
S: ServiceFactory<Request, Config = ()>,
S::Future: 'static,
S::Error: Into<Error> + 'static,
S::InitError: fmt::Debug,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service<Request>>::Future: 'static,
B: MessageBody + 'static,
X: ServiceFactory<Request, Config = (), Response = Request>,
X::Future: 'static,
X::Error: Into<Error>,
X::InitError: fmt::Debug,
U: ServiceFactory<(Request, Framed<T, h1::Codec>), Config = (), Response = ()>,
U::Future: 'static,
U::Error: fmt::Display + Into<Error>,

View File

@ -35,7 +35,10 @@ use std::{fmt, net, sync::mpsc, thread, time};
use actix_codec::{AsyncRead, AsyncWrite, Framed};
pub use actix_http::test::TestBuffer;
use actix_http::{http::Method, ws, HttpService, Request};
use actix_http::{
http::{HeaderMap, Method},
ws, HttpService, Request,
};
use actix_service::{map_config, IntoServiceFactory, ServiceFactory};
use actix_web::{
dev::{AppConfig, MessageBody, Server, Service},
@ -446,6 +449,14 @@ impl TestServer {
self.ws_at("/").await
}
/// Get default HeaderMap of Client.
///
/// Returns Some(&mut HeaderMap) when Client object is unique
/// (No other clone of client exists at the same time).
pub fn client_headers(&mut self) -> Option<&mut HeaderMap> {
self.client.headers()
}
/// Gracefully stop HTTP server.
pub async fn stop(self) {
self.server.stop(true).await;

View File

@ -1,7 +1,7 @@
use actix::prelude::*;
use actix_web::{
http::{header, StatusCode},
test, web, App, HttpRequest, HttpResponse,
web, App, HttpRequest, HttpResponse,
};
use actix_web_actors::*;
use bytes::Bytes;
@ -62,7 +62,7 @@ async fn test_simple() {
#[actix_rt::test]
async fn test_with_credentials() {
let mut srv = test::start(|| {
let mut srv = actix_test::start(|| {
App::new().service(web::resource("/").to(
|req: HttpRequest, stream: web::Payload| async move {
if req.headers().contains_key("Authorization") {

View File

@ -13,4 +13,3 @@ ignore: # ignore code coverage on following paths
- "**/tests"
- "**/benches"
- "**/examples"
- "test-server"

View File

@ -148,20 +148,13 @@ impl<T: ?Sized + 'static> DataFactory for Data<T> {
#[cfg(test)]
mod tests {
use std::sync::atomic::{AtomicUsize, Ordering};
use actix_service::Service;
use super::*;
use crate::dev::Service;
use crate::http::StatusCode;
use crate::test::{self, init_service, TestRequest};
use crate::{
dev::Service,
http::StatusCode,
test::{init_service, TestRequest},
web, App, HttpResponse,
};
use crate::{web, App, HttpResponse};
#[actix_rt::test]
async fn test_data_extractor() {

View File

@ -71,12 +71,15 @@ impl<F, I, S, B> HttpServer<F, I, S, B>
where
F: Fn() -> I + Send + Clone + 'static,
I: IntoServiceFactory<S, Request>,
S: ServiceFactory<Request, Config = AppConfig> + 'static,
// S::Future: 'static,
S::Error: Into<Error> + 'static,
S::InitError: fmt::Debug,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service<Request>>::Future: 'static,
S::Service: 'static,
// S::Service: 'static,
B: MessageBody + 'static,
{
/// Create new HTTP server with application factory
@ -347,6 +350,7 @@ where
}))
.openssl(acceptor.clone())
})?;
Ok(self)
}