mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
fix awc tests
This commit is contained in:
parent
c877840c07
commit
74fa4060c2
@ -14,8 +14,8 @@ use rand::Rng;
|
|||||||
|
|
||||||
use actix_http::HttpService;
|
use actix_http::HttpService;
|
||||||
use actix_http_test::test_server;
|
use actix_http_test::test_server;
|
||||||
use actix_service::pipeline_factory;
|
use actix_service::{map_config, pipeline_factory, IntoServiceFactory};
|
||||||
use actix_web::dev::BodyEncoding;
|
use actix_web::dev::{AppConfig, BodyEncoding};
|
||||||
use actix_web::http::Cookie;
|
use actix_web::http::Cookie;
|
||||||
use actix_web::middleware::Compress;
|
use actix_web::middleware::Compress;
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
@ -170,10 +170,12 @@ async fn test_connection_reuse() {
|
|||||||
ok(io)
|
ok(io)
|
||||||
})
|
})
|
||||||
.and_then(
|
.and_then(
|
||||||
HttpService::new(
|
HttpService::new(map_config(
|
||||||
App::new()
|
App::new()
|
||||||
.service(web::resource("/").route(web::to(|| HttpResponse::Ok()))),
|
.service(web::resource("/").route(web::to(|| HttpResponse::Ok())))
|
||||||
)
|
.into_factory(),
|
||||||
|
|_| AppConfig::default(),
|
||||||
|
))
|
||||||
.tcp(),
|
.tcp(),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
@ -206,10 +208,12 @@ async fn test_connection_force_close() {
|
|||||||
ok(io)
|
ok(io)
|
||||||
})
|
})
|
||||||
.and_then(
|
.and_then(
|
||||||
HttpService::new(
|
HttpService::new(map_config(
|
||||||
App::new()
|
App::new()
|
||||||
.service(web::resource("/").route(web::to(|| HttpResponse::Ok()))),
|
.service(web::resource("/").route(web::to(|| HttpResponse::Ok())))
|
||||||
)
|
.into_factory(),
|
||||||
|
|_| AppConfig::default(),
|
||||||
|
))
|
||||||
.tcp(),
|
.tcp(),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
@ -235,19 +239,22 @@ async fn test_connection_server_close() {
|
|||||||
let num = Arc::new(AtomicUsize::new(0));
|
let num = Arc::new(AtomicUsize::new(0));
|
||||||
let num2 = num.clone();
|
let num2 = num.clone();
|
||||||
|
|
||||||
let srv = test_server(move || {
|
let srv =
|
||||||
|
test_server(move || {
|
||||||
let num2 = num2.clone();
|
let num2 = num2.clone();
|
||||||
pipeline_factory(move |io| {
|
pipeline_factory(move |io| {
|
||||||
num2.fetch_add(1, Ordering::Relaxed);
|
num2.fetch_add(1, Ordering::Relaxed);
|
||||||
ok(io)
|
ok(io)
|
||||||
})
|
})
|
||||||
.and_then(
|
.and_then(
|
||||||
HttpService::new(
|
HttpService::new(map_config(
|
||||||
App::new().service(
|
App::new()
|
||||||
web::resource("/")
|
.service(web::resource("/").route(web::to(|| {
|
||||||
.route(web::to(|| HttpResponse::Ok().force_close().finish())),
|
HttpResponse::Ok().force_close().finish()
|
||||||
),
|
})))
|
||||||
)
|
.into_factory(),
|
||||||
|
|_| AppConfig::default(),
|
||||||
|
))
|
||||||
.tcp(),
|
.tcp(),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
@ -280,8 +287,14 @@ async fn test_connection_wait_queue() {
|
|||||||
ok(io)
|
ok(io)
|
||||||
})
|
})
|
||||||
.and_then(
|
.and_then(
|
||||||
HttpService::new(App::new().service(
|
HttpService::new(map_config(
|
||||||
web::resource("/").route(web::to(|| HttpResponse::Ok().body(STR))),
|
App::new()
|
||||||
|
.service(
|
||||||
|
web::resource("/")
|
||||||
|
.route(web::to(|| HttpResponse::Ok().body(STR))),
|
||||||
|
)
|
||||||
|
.into_factory(),
|
||||||
|
|_| AppConfig::default(),
|
||||||
))
|
))
|
||||||
.tcp(),
|
.tcp(),
|
||||||
)
|
)
|
||||||
@ -317,19 +330,22 @@ async fn test_connection_wait_queue_force_close() {
|
|||||||
let num = Arc::new(AtomicUsize::new(0));
|
let num = Arc::new(AtomicUsize::new(0));
|
||||||
let num2 = num.clone();
|
let num2 = num.clone();
|
||||||
|
|
||||||
let srv = test_server(move || {
|
let srv =
|
||||||
|
test_server(move || {
|
||||||
let num2 = num2.clone();
|
let num2 = num2.clone();
|
||||||
pipeline_factory(move |io| {
|
pipeline_factory(move |io| {
|
||||||
num2.fetch_add(1, Ordering::Relaxed);
|
num2.fetch_add(1, Ordering::Relaxed);
|
||||||
ok(io)
|
ok(io)
|
||||||
})
|
})
|
||||||
.and_then(
|
.and_then(
|
||||||
HttpService::new(
|
HttpService::new(map_config(
|
||||||
App::new().service(
|
App::new()
|
||||||
web::resource("/")
|
.service(web::resource("/").route(web::to(|| {
|
||||||
.route(web::to(|| HttpResponse::Ok().force_close().body(STR))),
|
HttpResponse::Ok().force_close().body(STR)
|
||||||
),
|
})))
|
||||||
)
|
.into_factory(),
|
||||||
|
|_| AppConfig::default(),
|
||||||
|
))
|
||||||
.tcp(),
|
.tcp(),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
@ -4,9 +4,9 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use actix_http::HttpService;
|
use actix_http::HttpService;
|
||||||
use actix_http_test::test_server;
|
use actix_http_test::test_server;
|
||||||
use actix_service::{pipeline_factory, ServiceFactory};
|
use actix_service::{map_config, pipeline_factory, ServiceFactory, IntoServiceFactory};
|
||||||
use actix_web::http::Version;
|
use actix_web::http::Version;
|
||||||
use actix_web::{web, App, HttpResponse};
|
use actix_web::{web, App, HttpResponse, dev::AppConfig};
|
||||||
use futures::future::ok;
|
use futures::future::ok;
|
||||||
use open_ssl::ssl::{SslAcceptor, SslFiletype, SslMethod, SslVerifyMode};
|
use open_ssl::ssl::{SslAcceptor, SslFiletype, SslMethod, SslVerifyMode};
|
||||||
use rust_tls::ClientConfig;
|
use rust_tls::ClientConfig;
|
||||||
@ -62,8 +62,11 @@ async fn _test_connection_reuse_h2() {
|
|||||||
})
|
})
|
||||||
.and_then(
|
.and_then(
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.h2(App::new()
|
.h2(map_config(App::new()
|
||||||
.service(web::resource("/").route(web::to(|| HttpResponse::Ok()))))
|
.service(web::resource("/").route(web::to(|| HttpResponse::Ok())))
|
||||||
|
.into_factory(),
|
||||||
|
|_| AppConfig::default(),
|
||||||
|
))
|
||||||
.openssl(ssl_acceptor())
|
.openssl(ssl_acceptor())
|
||||||
.map_err(|_| ()),
|
.map_err(|_| ()),
|
||||||
)
|
)
|
||||||
|
@ -4,9 +4,9 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use actix_http::HttpService;
|
use actix_http::HttpService;
|
||||||
use actix_http_test::test_server;
|
use actix_http_test::test_server;
|
||||||
use actix_service::{pipeline_factory, ServiceFactory};
|
use actix_service::{map_config, pipeline_factory, IntoServiceFactory, ServiceFactory};
|
||||||
use actix_web::http::Version;
|
use actix_web::http::Version;
|
||||||
use actix_web::{web, App, HttpResponse};
|
use actix_web::{dev::AppConfig, web, App, HttpResponse};
|
||||||
use futures::future::ok;
|
use futures::future::ok;
|
||||||
use open_ssl::ssl::{SslAcceptor, SslConnector, SslFiletype, SslMethod, SslVerifyMode};
|
use open_ssl::ssl::{SslAcceptor, SslConnector, SslFiletype, SslMethod, SslVerifyMode};
|
||||||
|
|
||||||
@ -44,8 +44,14 @@ async fn test_connection_reuse_h2() {
|
|||||||
})
|
})
|
||||||
.and_then(
|
.and_then(
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.h2(App::new()
|
.h2(map_config(
|
||||||
.service(web::resource("/").route(web::to(|| HttpResponse::Ok()))))
|
App::new()
|
||||||
|
.service(
|
||||||
|
web::resource("/").route(web::to(|| HttpResponse::Ok())),
|
||||||
|
)
|
||||||
|
.into_factory(),
|
||||||
|
|_| AppConfig::default(),
|
||||||
|
))
|
||||||
.openssl(ssl_acceptor())
|
.openssl(ssl_acceptor())
|
||||||
.map_err(|_| ()),
|
.map_err(|_| ()),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user