Skip to content

Commit

Permalink
test ci
Browse files Browse the repository at this point in the history
  • Loading branch information
hatoo committed Feb 9, 2025
1 parent eb06c48 commit 4f15e23
Showing 1 changed file with 34 additions and 36 deletions.
70 changes: 34 additions & 36 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,41 +750,39 @@ where
let proxy = Arc::new(http_mitm_proxy::MitmProxy::new(Some(cert), None));

let serve = async move {
loop {
let (stream, _) = tcp_listener.accept().await.unwrap();

let proxy = proxy.clone();
let service = service.clone();

let outer = service_fn(move |req| {
// Test --proxy-header option
assert_eq!(
req.headers()
.get("proxy-authorization")
.unwrap()
.to_str()
.unwrap(),
"test"
);

MitmProxy::wrap_service(proxy.clone(), service.clone()).call(req)
});

tokio::spawn(async move {
if http2 {
let _ = hyper::server::conn::http2::Builder::new(TokioExecutor::new())
.serve_connection(TokioIo::new(stream), outer)
.await;
} else {
let _ = hyper::server::conn::http1::Builder::new()
.preserve_header_case(true)
.title_case_headers(true)
.serve_connection(TokioIo::new(stream), outer)
.with_upgrades()
.await;
}
});
}
let (stream, _) = tcp_listener.accept().await.unwrap();

let proxy = proxy.clone();
let service = service.clone();

let outer = service_fn(move |req| {
// Test --proxy-header option
assert_eq!(
req.headers()
.get("proxy-authorization")
.unwrap()
.to_str()
.unwrap(),
"test"
);

MitmProxy::wrap_service(proxy.clone(), service.clone()).call(req)
});

tokio::spawn(async move {
if http2 {
let _ = hyper::server::conn::http2::Builder::new(TokioExecutor::new())
.serve_connection(TokioIo::new(stream), outer)
.await;
} else {
let _ = hyper::server::conn::http1::Builder::new()
.preserve_header_case(true)
.title_case_headers(true)
.serve_connection(TokioIo::new(stream), outer)
.with_upgrades()
.await;
}
});
};

(port, serve)
Expand Down Expand Up @@ -819,7 +817,7 @@ async fn test_proxy_with_setting(https: bool, http2: bool, proxy_http2: bool) {
}

// When std::process::Stdio::piped() is used, the wait_with_output() method will hang in Windows.
proc.stdin(std::process::Stdio::null())
proc.stdin(std::process::Stdio::inherit())
.stdout(std::process::Stdio::inherit())
.stderr(std::process::Stdio::inherit());
// So, we test status code only for now.
Expand Down

0 comments on commit 4f15e23

Please sign in to comment.