mirror of
https://github.com/actix/actix-web.git
synced 2024-12-21 23:56:35 +00:00
add async expect service test
This commit is contained in:
parent
b1547bbbb6
commit
bc58dbb2f5
1 changed files with 8 additions and 5 deletions
|
@ -9,6 +9,7 @@ use actix_service::{fn_cfg_factory, fn_service, NewService};
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use futures::future::{self, ok, Future};
|
use futures::future::{self, ok, Future};
|
||||||
use futures::stream::{once, Stream};
|
use futures::stream::{once, Stream};
|
||||||
|
use tokio_timer::sleep;
|
||||||
|
|
||||||
use actix_http::body::Body;
|
use actix_http::body::Body;
|
||||||
use actix_http::error::PayloadError;
|
use actix_http::error::PayloadError;
|
||||||
|
@ -185,11 +186,13 @@ fn test_expect_continue_h1() {
|
||||||
let srv = TestServer::new(|| {
|
let srv = TestServer::new(|| {
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.expect(fn_service(|req: Request| {
|
.expect(fn_service(|req: Request| {
|
||||||
if req.head().uri.query() == Some("yes=") {
|
sleep(Duration::from_millis(20)).then(move |_| {
|
||||||
Ok(req)
|
if req.head().uri.query() == Some("yes=") {
|
||||||
} else {
|
Ok(req)
|
||||||
Err(error::ErrorPreconditionFailed("error"))
|
} else {
|
||||||
}
|
Err(error::ErrorPreconditionFailed("error"))
|
||||||
|
}
|
||||||
|
})
|
||||||
}))
|
}))
|
||||||
.h1(|_| future::ok::<_, ()>(Response::Ok().finish()))
|
.h1(|_| future::ok::<_, ()>(Response::Ok().finish()))
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue