Update to tokio 1.0, bytes 1.0 (#1076)
Co-authored-by: Wim Looman <git@nemo157.com> Co-authored-by: Paolo Barbolini <paolo@paolo565.org>
This commit is contained in:
@@ -282,7 +282,9 @@ fn test_blocking_inside_a_runtime() {
|
||||
|
||||
let url = format!("http://{}/text", server.addr());
|
||||
|
||||
let mut rt = tokio::runtime::Builder::new().build().expect("new rt");
|
||||
let rt = tokio::runtime::Builder::new_current_thread()
|
||||
.build()
|
||||
.expect("new rt");
|
||||
|
||||
rt.block_on(async move {
|
||||
let _should_panic = reqwest::blocking::get(&url);
|
||||
|
||||
@@ -155,14 +155,15 @@ fn test_redirect_307_does_not_try_if_reader_cannot_reset() {
|
||||
async fn test_redirect_removes_sensitive_headers() {
|
||||
use tokio::sync::watch;
|
||||
|
||||
let (tx, rx) = watch::channel(None);
|
||||
let (tx, rx) = watch::channel::<Option<std::net::SocketAddr>>(None);
|
||||
|
||||
let end_server = server::http(move |req| {
|
||||
let mut rx = rx.clone();
|
||||
async move {
|
||||
assert_eq!(req.headers().get("cookie"), None);
|
||||
|
||||
let mid_addr = rx.recv().await.unwrap().unwrap();
|
||||
rx.changed().await.unwrap();
|
||||
let mid_addr = rx.borrow().unwrap();
|
||||
assert_eq!(
|
||||
req.headers()["referer"],
|
||||
format!("http://{}/sensitive", mid_addr)
|
||||
@@ -182,7 +183,7 @@ async fn test_redirect_removes_sensitive_headers() {
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
tx.broadcast(Some(mid_server.addr())).unwrap();
|
||||
tx.send(Some(mid_server.addr())).unwrap();
|
||||
|
||||
reqwest::Client::builder()
|
||||
.build()
|
||||
|
||||
@@ -44,8 +44,7 @@ where
|
||||
{
|
||||
//Spawn new runtime in thread to prevent reactor execution context conflict
|
||||
thread::spawn(move || {
|
||||
let mut rt = runtime::Builder::new()
|
||||
.basic_scheduler()
|
||||
let rt = runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.expect("new rt");
|
||||
|
||||
@@ -11,7 +11,7 @@ async fn client_timeout() {
|
||||
let server = server::http(move |_req| {
|
||||
async {
|
||||
// delay returning the response
|
||||
tokio::time::delay_for(Duration::from_secs(2)).await;
|
||||
tokio::time::sleep(Duration::from_secs(2)).await;
|
||||
http::Response::default()
|
||||
}
|
||||
});
|
||||
@@ -38,7 +38,7 @@ async fn request_timeout() {
|
||||
let server = server::http(move |_req| {
|
||||
async {
|
||||
// delay returning the response
|
||||
tokio::time::delay_for(Duration::from_secs(2)).await;
|
||||
tokio::time::sleep(Duration::from_secs(2)).await;
|
||||
http::Response::default()
|
||||
}
|
||||
});
|
||||
@@ -94,7 +94,7 @@ async fn response_timeout() {
|
||||
async {
|
||||
// immediate response, but delayed body
|
||||
let body = hyper::Body::wrap_stream(futures_util::stream::once(async {
|
||||
tokio::time::delay_for(Duration::from_secs(2)).await;
|
||||
tokio::time::sleep(Duration::from_secs(2)).await;
|
||||
Ok::<_, std::convert::Infallible>("Hello")
|
||||
}));
|
||||
|
||||
@@ -134,7 +134,7 @@ fn timeout_closes_connection() {
|
||||
let server = server::http(move |_req| {
|
||||
async {
|
||||
// delay returning the response
|
||||
tokio::time::delay_for(Duration::from_secs(2)).await;
|
||||
tokio::time::sleep(Duration::from_secs(2)).await;
|
||||
http::Response::default()
|
||||
}
|
||||
});
|
||||
@@ -158,7 +158,7 @@ fn timeout_blocking_request() {
|
||||
let server = server::http(move |_req| {
|
||||
async {
|
||||
// delay returning the response
|
||||
tokio::time::delay_for(Duration::from_secs(2)).await;
|
||||
tokio::time::sleep(Duration::from_secs(2)).await;
|
||||
http::Response::default()
|
||||
}
|
||||
});
|
||||
@@ -191,7 +191,7 @@ fn write_timeout_large_body() {
|
||||
let server = server::http(move |_req| {
|
||||
async {
|
||||
// delay returning the response
|
||||
tokio::time::delay_for(Duration::from_secs(2)).await;
|
||||
tokio::time::sleep(Duration::from_secs(2)).await;
|
||||
http::Response::default()
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user