mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-30 00:14:58 +02:00
@ -15,26 +15,30 @@ async fn test_start() {
|
||||
thread::spawn(move || {
|
||||
let sys = actix_rt::System::new("test");
|
||||
|
||||
let srv = HttpServer::new(|| {
|
||||
App::new().service(
|
||||
web::resource("/").route(web::to(|| HttpResponse::Ok().body("test"))),
|
||||
)
|
||||
})
|
||||
.workers(1)
|
||||
.backlog(1)
|
||||
.max_connections(10)
|
||||
.max_connection_rate(10)
|
||||
.keep_alive(10)
|
||||
.client_timeout(5000)
|
||||
.client_shutdown(0)
|
||||
.server_hostname("localhost")
|
||||
.system_exit()
|
||||
.disable_signals()
|
||||
.bind(format!("{}", addr))
|
||||
.unwrap()
|
||||
.run();
|
||||
sys.block_on(async {
|
||||
let srv = HttpServer::new(|| {
|
||||
App::new().service(
|
||||
web::resource("/")
|
||||
.route(web::to(|| HttpResponse::Ok().body("test"))),
|
||||
)
|
||||
})
|
||||
.workers(1)
|
||||
.backlog(1)
|
||||
.max_connections(10)
|
||||
.max_connection_rate(10)
|
||||
.keep_alive(10)
|
||||
.client_timeout(5000)
|
||||
.client_shutdown(0)
|
||||
.server_hostname("localhost")
|
||||
.system_exit()
|
||||
.disable_signals()
|
||||
.bind(format!("{}", addr))
|
||||
.unwrap()
|
||||
.run();
|
||||
|
||||
let _ = tx.send((srv, actix_rt::System::current()));
|
||||
});
|
||||
|
||||
let _ = tx.send((srv, actix_rt::System::current()));
|
||||
let _ = sys.run();
|
||||
});
|
||||
let (srv, sys) = rx.recv().unwrap();
|
||||
@ -101,10 +105,13 @@ async fn test_start_ssl() {
|
||||
.system_exit()
|
||||
.disable_signals()
|
||||
.bind_openssl(format!("{}", addr), builder)
|
||||
.unwrap()
|
||||
.run();
|
||||
.unwrap();
|
||||
|
||||
sys.block_on(async {
|
||||
let srv = srv.run();
|
||||
let _ = tx.send((srv, actix_rt::System::current()));
|
||||
});
|
||||
|
||||
let _ = tx.send((srv, actix_rt::System::current()));
|
||||
let _ = sys.run();
|
||||
});
|
||||
let (srv, sys) = rx.recv().unwrap();
|
||||
|
@ -45,7 +45,7 @@ const STR: &str = "Hello World Hello World Hello World Hello World Hello World \
|
||||
struct TestBody {
|
||||
data: Bytes,
|
||||
chunk_size: usize,
|
||||
delay: actix_rt::time::Delay,
|
||||
delay: Pin<Box<actix_rt::time::Sleep>>,
|
||||
}
|
||||
|
||||
impl TestBody {
|
||||
@ -53,7 +53,7 @@ impl TestBody {
|
||||
TestBody {
|
||||
data,
|
||||
chunk_size,
|
||||
delay: actix_rt::time::delay_for(std::time::Duration::from_millis(10)),
|
||||
delay: Box::pin(actix_rt::time::sleep(std::time::Duration::from_millis(10))),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -67,7 +67,8 @@ impl futures_core::stream::Stream for TestBody {
|
||||
) -> Poll<Option<Self::Item>> {
|
||||
ready!(Pin::new(&mut self.delay).poll(cx));
|
||||
|
||||
self.delay = actix_rt::time::delay_for(std::time::Duration::from_millis(10));
|
||||
self.delay =
|
||||
Box::pin(actix_rt::time::sleep(std::time::Duration::from_millis(10)));
|
||||
let chunk_size = std::cmp::min(self.chunk_size, self.data.len());
|
||||
let chunk = self.data.split_to(chunk_size);
|
||||
if chunk.is_empty() {
|
||||
|
Reference in New Issue
Block a user