mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-11 22:53:00 +00:00
refactor(cli): centralize HTTP client builder with User-Agent header
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5ece2f915e
commit
a2672aef46
2 changed files with 8 additions and 3 deletions
|
|
@ -211,7 +211,7 @@ fn normalize_remote_server_target(api_url: &str) -> String {
|
|||
}
|
||||
|
||||
pub(crate) async fn connect_unix_socket_api_client(path: &Path) -> Result<fabro_api::Client> {
|
||||
let http_client = reqwest::ClientBuilder::new()
|
||||
let http_client = crate::user_config::cli_http_client_builder()
|
||||
.unix_socket(path)
|
||||
.no_proxy()
|
||||
.build()
|
||||
|
|
|
|||
|
|
@ -132,11 +132,16 @@ pub(crate) fn exec_server_target(
|
|||
Ok(target)
|
||||
}
|
||||
|
||||
pub(crate) fn cli_http_client_builder() -> reqwest::ClientBuilder {
|
||||
reqwest::Client::builder()
|
||||
.user_agent(format!("fabro-cli/{}", fabro_util::version::FABRO_VERSION))
|
||||
}
|
||||
|
||||
pub(crate) fn build_server_client(
|
||||
tls: Option<&ClientTlsSettings>,
|
||||
) -> anyhow::Result<reqwest::Client> {
|
||||
let Some(tls) = tls else {
|
||||
return Ok(reqwest::Client::new());
|
||||
return Ok(cli_http_client_builder().build()?);
|
||||
};
|
||||
|
||||
let cert_path = fabro_config::expand_tilde(&tls.cert);
|
||||
|
|
@ -154,7 +159,7 @@ pub(crate) fn build_server_client(
|
|||
let identity = reqwest::Identity::from_pem(&identity_pem)?;
|
||||
let ca_cert = reqwest::Certificate::from_pem(&ca_pem)?;
|
||||
|
||||
let client = reqwest::Client::builder()
|
||||
let client = cli_http_client_builder()
|
||||
.use_rustls_tls()
|
||||
.identity(identity)
|
||||
.add_root_certificate(ca_cert)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue