mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
Update tests
This commit is contained in:
parent
a9a475d555
commit
e718f65121
@ -47,7 +47,8 @@ async fn test_simple() {
|
||||
)
|
||||
.finish(|_| future::ok::<_, Error>(Response::NotFound()))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
assert!(srv.ws_at("/test").await.is_err());
|
||||
|
||||
@ -108,7 +109,8 @@ async fn test_service() {
|
||||
.map_err(|_| ()),
|
||||
),
|
||||
)
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
// non ws request
|
||||
let res = srv.get("/index.html").send().await.unwrap();
|
||||
|
@ -33,7 +33,8 @@ async fn test_h1_v2() {
|
||||
HttpService::build()
|
||||
.finish(|_| future::ok::<_, ()>(Response::Ok().body(STR)))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.get("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -61,7 +62,8 @@ async fn test_connection_close() {
|
||||
.finish(|_| ok::<_, ()>(Response::Ok().body(STR)))
|
||||
.tcp()
|
||||
.map(|_| ())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.get("/").force_close().send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -80,7 +82,8 @@ async fn test_with_query_parameter() {
|
||||
})
|
||||
.tcp()
|
||||
.map(|_| ())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let request = srv.request(http::Method::GET, srv.url("/?qp=5"));
|
||||
let response = request.send().await.unwrap();
|
||||
|
@ -67,7 +67,8 @@ async fn test_h2() -> io::Result<()> {
|
||||
.h2(|_| ok::<_, Error>(Response::Ok().finish()))
|
||||
.openssl(ssl_acceptor())
|
||||
.map_err(|_| ())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -85,7 +86,8 @@ async fn test_h2_1() -> io::Result<()> {
|
||||
})
|
||||
.openssl(ssl_acceptor())
|
||||
.map_err(|_| ())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -103,7 +105,8 @@ async fn test_h2_body() -> io::Result<()> {
|
||||
})
|
||||
.openssl(ssl_acceptor())
|
||||
.map_err(|_| ())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send_body(data.clone()).await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -131,7 +134,8 @@ async fn test_h2_content_length() {
|
||||
})
|
||||
.openssl(ssl_acceptor())
|
||||
.map_err(|_| ())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let header = HeaderName::from_static("content-length");
|
||||
let value = HeaderValue::from_static("0");
|
||||
@ -192,7 +196,7 @@ async fn test_h2_headers() {
|
||||
})
|
||||
.openssl(ssl_acceptor())
|
||||
.map_err(|_| ())
|
||||
});
|
||||
}).await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -231,7 +235,8 @@ async fn test_h2_body2() {
|
||||
.h2(|_| ok::<_, ()>(Response::Ok().body(STR)))
|
||||
.openssl(ssl_acceptor())
|
||||
.map_err(|_| ())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -248,7 +253,8 @@ async fn test_h2_head_empty() {
|
||||
.finish(|_| ok::<_, ()>(Response::Ok().body(STR)))
|
||||
.openssl(ssl_acceptor())
|
||||
.map_err(|_| ())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.shead("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -273,7 +279,8 @@ async fn test_h2_head_binary() {
|
||||
})
|
||||
.openssl(ssl_acceptor())
|
||||
.map_err(|_| ())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.shead("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -295,7 +302,8 @@ async fn test_h2_head_binary2() {
|
||||
.h2(|_| ok::<_, ()>(Response::Ok().body(STR)))
|
||||
.openssl(ssl_acceptor())
|
||||
.map_err(|_| ())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.shead("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -318,7 +326,8 @@ async fn test_h2_body_length() {
|
||||
})
|
||||
.openssl(ssl_acceptor())
|
||||
.map_err(|_| ())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -342,7 +351,8 @@ async fn test_h2_body_chunked_explicit() {
|
||||
})
|
||||
.openssl(ssl_acceptor())
|
||||
.map_err(|_| ())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -369,7 +379,8 @@ async fn test_h2_response_http_error_handling() {
|
||||
}))
|
||||
.openssl(ssl_acceptor())
|
||||
.map_err(|_| ())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert_eq!(response.status(), StatusCode::INTERNAL_SERVER_ERROR);
|
||||
@ -386,7 +397,8 @@ async fn test_h2_service_error() {
|
||||
.h2(|_| err::<Response, Error>(ErrorBadRequest("error")))
|
||||
.openssl(ssl_acceptor())
|
||||
.map_err(|_| ())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert_eq!(response.status(), StatusCode::BAD_REQUEST);
|
||||
@ -407,7 +419,8 @@ async fn test_h2_on_connect() {
|
||||
})
|
||||
.openssl(ssl_acceptor())
|
||||
.map_err(|_| ())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
|
@ -45,7 +45,8 @@ async fn test_h1() -> io::Result<()> {
|
||||
HttpService::build()
|
||||
.h1(|_| future::ok::<_, Error>(Response::Ok().finish()))
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -58,7 +59,8 @@ async fn test_h2() -> io::Result<()> {
|
||||
HttpService::build()
|
||||
.h2(|_| future::ok::<_, Error>(Response::Ok().finish()))
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -75,7 +77,8 @@ async fn test_h1_1() -> io::Result<()> {
|
||||
future::ok::<_, Error>(Response::Ok().finish())
|
||||
})
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -92,7 +95,8 @@ async fn test_h2_1() -> io::Result<()> {
|
||||
future::ok::<_, Error>(Response::Ok().finish())
|
||||
})
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -109,7 +113,8 @@ async fn test_h2_body1() -> io::Result<()> {
|
||||
Ok::<_, Error>(Response::Ok().body(body))
|
||||
})
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send_body(data.clone()).await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -136,7 +141,8 @@ async fn test_h2_content_length() {
|
||||
future::ok::<_, ()>(Response::new(statuses[indx]))
|
||||
})
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let header = HeaderName::from_static("content-length");
|
||||
let value = HeaderValue::from_static("0");
|
||||
@ -195,7 +201,7 @@ async fn test_h2_headers() {
|
||||
future::ok::<_, ()>(config.body(data.clone()))
|
||||
})
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
}).await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -233,7 +239,8 @@ async fn test_h2_body2() {
|
||||
HttpService::build()
|
||||
.h2(|_| future::ok::<_, ()>(Response::Ok().body(STR)))
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -249,7 +256,8 @@ async fn test_h2_head_empty() {
|
||||
HttpService::build()
|
||||
.finish(|_| ok::<_, ()>(Response::Ok().body(STR)))
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.shead("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -276,7 +284,8 @@ async fn test_h2_head_binary() {
|
||||
ok::<_, ()>(Response::Ok().content_length(STR.len() as u64).body(STR))
|
||||
})
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.shead("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -300,7 +309,8 @@ async fn test_h2_head_binary2() {
|
||||
HttpService::build()
|
||||
.h2(|_| ok::<_, ()>(Response::Ok().body(STR)))
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.shead("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -325,7 +335,8 @@ async fn test_h2_body_length() {
|
||||
)
|
||||
})
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -348,7 +359,8 @@ async fn test_h2_body_chunked_explicit() {
|
||||
)
|
||||
})
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -376,7 +388,8 @@ async fn test_h2_response_http_error_handling() {
|
||||
}))
|
||||
}))
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert_eq!(response.status(), http::StatusCode::INTERNAL_SERVER_ERROR);
|
||||
@ -392,7 +405,8 @@ async fn test_h2_service_error() {
|
||||
HttpService::build()
|
||||
.h2(|_| err::<Response, Error>(error::ErrorBadRequest("error")))
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert_eq!(response.status(), http::StatusCode::BAD_REQUEST);
|
||||
@ -408,7 +422,8 @@ async fn test_h1_service_error() {
|
||||
HttpService::build()
|
||||
.h1(|_| err::<Response, Error>(error::ErrorBadRequest("error")))
|
||||
.rustls(ssl_acceptor())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.sget("/").send().await.unwrap();
|
||||
assert_eq!(response.status(), http::StatusCode::BAD_REQUEST);
|
||||
|
@ -27,7 +27,8 @@ async fn test_h1() {
|
||||
future::ok::<_, ()>(Response::Ok().finish())
|
||||
})
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.get("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -46,7 +47,8 @@ async fn test_h1_2() {
|
||||
future::ok::<_, ()>(Response::Ok().finish())
|
||||
})
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.get("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -65,7 +67,8 @@ async fn test_expect_continue() {
|
||||
}))
|
||||
.finish(|_| future::ok::<_, ()>(Response::Ok().finish()))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let mut stream = net::TcpStream::connect(srv.addr()).unwrap();
|
||||
let _ = stream.write_all(b"GET /test HTTP/1.1\r\nexpect: 100-continue\r\n\r\n");
|
||||
@ -95,7 +98,8 @@ async fn test_expect_continue_h1() {
|
||||
}))
|
||||
.h1(fn_service(|_| future::ok::<_, ()>(Response::Ok().finish())))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let mut stream = net::TcpStream::connect(srv.addr()).unwrap();
|
||||
let _ = stream.write_all(b"GET /test HTTP/1.1\r\nexpect: 100-continue\r\n\r\n");
|
||||
@ -130,7 +134,8 @@ async fn test_chunked_payload() {
|
||||
})
|
||||
}))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let returned_size = {
|
||||
let mut stream = net::TcpStream::connect(srv.addr()).unwrap();
|
||||
@ -172,7 +177,8 @@ async fn test_slow_request() {
|
||||
.client_timeout(100)
|
||||
.finish(|_| future::ok::<_, ()>(Response::Ok().finish()))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let mut stream = net::TcpStream::connect(srv.addr()).unwrap();
|
||||
let _ = stream.write_all(b"GET /test/tests/test HTTP/1.1\r\n");
|
||||
@ -187,7 +193,8 @@ async fn test_http1_malformed_request() {
|
||||
HttpService::build()
|
||||
.h1(|_| future::ok::<_, ()>(Response::Ok().finish()))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let mut stream = net::TcpStream::connect(srv.addr()).unwrap();
|
||||
let _ = stream.write_all(b"GET /test/tests/test HTTP1.1\r\n");
|
||||
@ -202,7 +209,8 @@ async fn test_http1_keepalive() {
|
||||
HttpService::build()
|
||||
.h1(|_| future::ok::<_, ()>(Response::Ok().finish()))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let mut stream = net::TcpStream::connect(srv.addr()).unwrap();
|
||||
let _ = stream.write_all(b"GET /test/tests/test HTTP/1.1\r\n\r\n");
|
||||
@ -223,7 +231,8 @@ async fn test_http1_keepalive_timeout() {
|
||||
.keep_alive(1)
|
||||
.h1(|_| future::ok::<_, ()>(Response::Ok().finish()))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let mut stream = net::TcpStream::connect(srv.addr()).unwrap();
|
||||
let _ = stream.write_all(b"GET /test/tests/test HTTP/1.1\r\n\r\n");
|
||||
@ -243,7 +252,8 @@ async fn test_http1_keepalive_close() {
|
||||
HttpService::build()
|
||||
.h1(|_| future::ok::<_, ()>(Response::Ok().finish()))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let mut stream = net::TcpStream::connect(srv.addr()).unwrap();
|
||||
let _ =
|
||||
@ -263,7 +273,8 @@ async fn test_http10_keepalive_default_close() {
|
||||
HttpService::build()
|
||||
.h1(|_| future::ok::<_, ()>(Response::Ok().finish()))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let mut stream = net::TcpStream::connect(srv.addr()).unwrap();
|
||||
let _ = stream.write_all(b"GET /test/tests/test HTTP/1.0\r\n\r\n");
|
||||
@ -282,7 +293,8 @@ async fn test_http10_keepalive() {
|
||||
HttpService::build()
|
||||
.h1(|_| future::ok::<_, ()>(Response::Ok().finish()))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let mut stream = net::TcpStream::connect(srv.addr()).unwrap();
|
||||
let _ = stream
|
||||
@ -309,7 +321,8 @@ async fn test_http1_keepalive_disabled() {
|
||||
.keep_alive(KeepAlive::Disabled)
|
||||
.h1(|_| future::ok::<_, ()>(Response::Ok().finish()))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let mut stream = net::TcpStream::connect(srv.addr()).unwrap();
|
||||
let _ = stream.write_all(b"GET /test/tests/test HTTP/1.1\r\n\r\n");
|
||||
@ -344,7 +357,8 @@ async fn test_content_length() {
|
||||
future::ok::<_, ()>(Response::new(statuses[indx]))
|
||||
})
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let header = HeaderName::from_static("content-length");
|
||||
let value = HeaderValue::from_static("0");
|
||||
@ -397,7 +411,7 @@ async fn test_h1_headers() {
|
||||
}
|
||||
future::ok::<_, ()>(builder.body(data.clone()))
|
||||
}).tcp()
|
||||
});
|
||||
}).await;
|
||||
|
||||
let response = srv.get("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -435,7 +449,8 @@ async fn test_h1_body() {
|
||||
HttpService::build()
|
||||
.h1(|_| ok::<_, ()>(Response::Ok().body(STR)))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.get("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -451,7 +466,8 @@ async fn test_h1_head_empty() {
|
||||
HttpService::build()
|
||||
.h1(|_| ok::<_, ()>(Response::Ok().body(STR)))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.head("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -477,7 +493,8 @@ async fn test_h1_head_binary() {
|
||||
ok::<_, ()>(Response::Ok().content_length(STR.len() as u64).body(STR))
|
||||
})
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.head("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -501,7 +518,8 @@ async fn test_h1_head_binary2() {
|
||||
HttpService::build()
|
||||
.h1(|_| ok::<_, ()>(Response::Ok().body(STR)))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.head("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -526,7 +544,8 @@ async fn test_h1_body_length() {
|
||||
)
|
||||
})
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.get("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -549,7 +568,8 @@ async fn test_h1_body_chunked_explicit() {
|
||||
)
|
||||
})
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.get("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -579,7 +599,8 @@ async fn test_h1_body_chunked_implicit() {
|
||||
ok::<_, ()>(Response::Ok().streaming(body))
|
||||
})
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.get("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
@ -611,7 +632,8 @@ async fn test_h1_response_http_error_handling() {
|
||||
)
|
||||
}))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.get("/").send().await.unwrap();
|
||||
assert_eq!(response.status(), http::StatusCode::INTERNAL_SERVER_ERROR);
|
||||
@ -627,7 +649,8 @@ async fn test_h1_service_error() {
|
||||
HttpService::build()
|
||||
.h1(|_| future::err::<Response, Error>(error::ErrorBadRequest("error")))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.get("/").send().await.unwrap();
|
||||
assert_eq!(response.status(), http::StatusCode::BAD_REQUEST);
|
||||
@ -647,7 +670,8 @@ async fn test_h1_on_connect() {
|
||||
future::ok::<_, ()>(Response::Ok().finish())
|
||||
})
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let response = srv.get("/").send().await.unwrap();
|
||||
assert!(response.status().is_success());
|
||||
|
@ -93,7 +93,8 @@ async fn test_simple() {
|
||||
.finish(|_| future::ok::<_, ()>(Response::NotFound()))
|
||||
.tcp()
|
||||
}
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
// client service
|
||||
let mut framed = srv.ws().await.unwrap();
|
||||
|
@ -5,10 +5,10 @@ use std::rc::Rc;
|
||||
use std::time::Duration;
|
||||
|
||||
use actix_http::client::{Connect as HttpConnect, ConnectError, Connection, Connector};
|
||||
use actix_http::http::{header, Error as HttpError, HeaderMap, HeaderName, self};
|
||||
use actix_http::http::{self, header, Error as HttpError, HeaderMap, HeaderName};
|
||||
use actix_service::Service;
|
||||
|
||||
use crate::connect::{ConnectorWrapper, Connect};
|
||||
use crate::connect::{Connect, ConnectorWrapper};
|
||||
use crate::{Client, ClientConfig};
|
||||
|
||||
/// An HTTP Client builder
|
||||
@ -182,7 +182,9 @@ impl ClientBuilder {
|
||||
if let Some(val) = self.stream_window_size {
|
||||
connector = connector.initial_window_size(val)
|
||||
};
|
||||
RefCell::new(Box::new(ConnectorWrapper(connector.finish())) as Box<dyn Connect>)
|
||||
RefCell::new(
|
||||
Box::new(ConnectorWrapper(connector.finish())) as Box<dyn Connect>
|
||||
)
|
||||
};
|
||||
let config = ClientConfig {
|
||||
headers: self.headers,
|
||||
|
@ -107,17 +107,15 @@ async fn test_form() {
|
||||
#[actix_rt::test]
|
||||
async fn test_timeout() {
|
||||
let srv = test::start(|| {
|
||||
App::new().service(web::resource("/").route(web::to(|| {
|
||||
async {
|
||||
actix_rt::time::delay_for(Duration::from_millis(200)).await;
|
||||
Ok::<_, Error>(HttpResponse::Ok().body(STR))
|
||||
}
|
||||
App::new().service(web::resource("/").route(web::to(|| async {
|
||||
actix_rt::time::delay_for(Duration::from_millis(200)).await;
|
||||
Ok::<_, Error>(HttpResponse::Ok().body(STR))
|
||||
})))
|
||||
});
|
||||
|
||||
let connector = awc::Connector::new()
|
||||
.connector(actix_connect::new_connector(
|
||||
actix_connect::start_default_resolver(),
|
||||
actix_connect::start_default_resolver().await.unwrap(),
|
||||
))
|
||||
.timeout(Duration::from_secs(15))
|
||||
.finish();
|
||||
@ -137,11 +135,9 @@ async fn test_timeout() {
|
||||
#[actix_rt::test]
|
||||
async fn test_timeout_override() {
|
||||
let srv = test::start(|| {
|
||||
App::new().service(web::resource("/").route(web::to(|| {
|
||||
async {
|
||||
actix_rt::time::delay_for(Duration::from_millis(200)).await;
|
||||
Ok::<_, Error>(HttpResponse::Ok().body(STR))
|
||||
}
|
||||
App::new().service(web::resource("/").route(web::to(|| async {
|
||||
actix_rt::time::delay_for(Duration::from_millis(200)).await;
|
||||
Ok::<_, Error>(HttpResponse::Ok().body(STR))
|
||||
})))
|
||||
});
|
||||
|
||||
@ -177,7 +173,8 @@ async fn test_connection_reuse() {
|
||||
))
|
||||
.tcp(),
|
||||
)
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let client = awc::Client::default();
|
||||
|
||||
@ -214,7 +211,8 @@ async fn test_connection_force_close() {
|
||||
))
|
||||
.tcp(),
|
||||
)
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let client = awc::Client::default();
|
||||
|
||||
@ -253,7 +251,8 @@ async fn test_connection_server_close() {
|
||||
))
|
||||
.tcp(),
|
||||
)
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let client = awc::Client::default();
|
||||
|
||||
@ -291,7 +290,8 @@ async fn test_connection_wait_queue() {
|
||||
))
|
||||
.tcp(),
|
||||
)
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let client = awc::Client::build()
|
||||
.connector(awc::Connector::new().limit(1).finish())
|
||||
@ -339,7 +339,8 @@ async fn test_connection_wait_queue_force_close() {
|
||||
))
|
||||
.tcp(),
|
||||
)
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
let client = awc::Client::build()
|
||||
.connector(awc::Connector::new().limit(1).finish())
|
||||
|
@ -32,14 +32,14 @@ async fn test_connection_window_size() {
|
||||
let srv = test_server(move || {
|
||||
HttpService::build()
|
||||
.h2(map_config(
|
||||
App::new().service(
|
||||
web::resource("/").route(web::to(|| HttpResponse::Ok())),
|
||||
),
|
||||
App::new()
|
||||
.service(web::resource("/").route(web::to(|| HttpResponse::Ok()))),
|
||||
|_| AppConfig::default(),
|
||||
))
|
||||
.openssl(ssl_acceptor())
|
||||
.map_err(|_| ())
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
// disable ssl verification
|
||||
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();
|
||||
|
@ -72,7 +72,8 @@ async fn _test_connection_reuse_h2() {
|
||||
.openssl(ssl_acceptor())
|
||||
.map_err(|_| ()),
|
||||
)
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
// disable ssl verification
|
||||
let mut config = ClientConfig::new();
|
||||
|
@ -53,7 +53,8 @@ async fn test_connection_reuse_h2() {
|
||||
.openssl(ssl_acceptor())
|
||||
.map_err(|_| ()),
|
||||
)
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
// disable ssl verification
|
||||
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();
|
||||
|
@ -38,7 +38,8 @@ async fn test_simple() {
|
||||
})
|
||||
.finish(|_| ok::<_, Error>(Response::NotFound()))
|
||||
.tcp()
|
||||
});
|
||||
})
|
||||
.await;
|
||||
|
||||
// client service
|
||||
let mut framed = srv.ws().await.unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user