Extract http from util (#11680)

This avoids the CLI linking libssl etc...

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2024-05-10 15:50:20 -06:00 committed by GitHub
parent df41435d1a
commit 5515ba6043
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
77 changed files with 419 additions and 336 deletions

View file

@ -1,7 +1,5 @@
pub mod arc_cow;
pub mod fs;
pub mod github;
pub mod http;
pub mod paths;
pub mod serde;
#[cfg(any(test, feature = "test-support"))]
@ -43,28 +41,6 @@ pub fn truncate(s: &str, max_chars: usize) -> &str {
}
}
pub fn http_proxy_from_env() -> Option<isahc::http::Uri> {
macro_rules! try_env {
($($env:literal),+) => {
$(
if let Ok(env) = std::env::var($env) {
return env.parse::<isahc::http::Uri>().ok();
}
)+
};
}
try_env!(
"ALL_PROXY",
"all_proxy",
"HTTPS_PROXY",
"https_proxy",
"HTTP_PROXY",
"http_proxy"
);
None
}
/// Removes characters from the end of the string if its length is greater than `max_chars` and
/// appends "..." to the string. Returns string unchanged if its length is smaller than max_chars.
pub fn truncate_and_trailoff(s: &str, max_chars: usize) -> String {