1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-25 06:39:22 +02:00

add per request timeout

This commit is contained in:
Nikolay Kim
2019-03-29 14:07:37 -07:00
parent 058b1d56e6
commit 744d82431d
4 changed files with 47 additions and 8 deletions

View File

@ -83,6 +83,32 @@ fn test_timeout() {
}
}
#[test]
fn test_timeout_override() {
let mut srv = TestServer::new(|| {
HttpService::new(App::new().service(web::resource("/").route(web::to_async(
|| {
tokio_timer::sleep(Duration::from_millis(200))
.then(|_| Ok::<_, Error>(HttpResponse::Ok().body(STR)))
},
))))
});
let client = srv.execute(|| {
awc::Client::build()
.timeout(Duration::from_millis(50000))
.finish()
});
let request = client
.get(srv.url("/"))
.timeout(Duration::from_millis(50))
.send();
match srv.block_on(request) {
Err(SendRequestError::Timeout) => (),
_ => panic!(),
}
}
// #[test]
// fn test_connection_close() {
// let mut srv =