http_client: Remove unused HttpClient::type_name method (#42803)

Closes #ISSUE

Remove unused method `HttpClient::type_name`. Looking at the PR from a
year ago when it was added, it was never actually used for anything and
seems like a prototyping artifact.

Other misc changes for the `http_client` crate include:

- Use `derive_more::Deref` for `HttpClientWithUrl` (already used for
`HttpClientWithProxy`)
- Move `http_client::proxy()` higher up in the trait definition. (It was
in between methods that have default implementations)

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
tidely
2025-11-17 15:28:22 +01:00
committed by GitHub
parent 4092e81ada
commit 9bebf314e0
3 changed files with 7 additions and 39 deletions
-4
View File
@@ -2400,10 +2400,6 @@ impl HttpClient for NullHttpClient {
fn proxy(&self) -> Option<&Url> {
None
}
fn type_name(&self) -> &'static str {
type_name::<Self>()
}
}
/// A mutable reference to an entity owned by GPUI
+6 -30
View File
@@ -14,9 +14,9 @@ use futures::{
};
use parking_lot::Mutex;
use serde::Serialize;
use std::sync::Arc;
#[cfg(feature = "test-support")]
use std::fmt;
use std::{any::type_name, sync::Arc};
use std::{any::type_name, fmt};
pub use url::{Host, Url};
#[derive(Default, Debug, Clone, PartialEq, Eq, Hash)]
@@ -59,10 +59,10 @@ impl HttpRequestExt for http::request::Builder {
}
pub trait HttpClient: 'static + Send + Sync {
fn type_name(&self) -> &'static str;
fn user_agent(&self) -> Option<&HeaderValue>;
fn proxy(&self) -> Option<&Url>;
fn send(
&self,
req: http::Request<AsyncBody>,
@@ -106,8 +106,6 @@ pub trait HttpClient: 'static + Send + Sync {
}
}
fn proxy(&self) -> Option<&Url>;
#[cfg(feature = "test-support")]
fn as_fake(&self) -> &FakeHttpClient {
panic!("called as_fake on {}", type_name::<Self>())
@@ -163,10 +161,6 @@ impl HttpClient for HttpClientWithProxy {
self.proxy.as_ref()
}
fn type_name(&self) -> &'static str {
self.client.type_name()
}
#[cfg(feature = "test-support")]
fn as_fake(&self) -> &FakeHttpClient {
self.client.as_fake()
@@ -182,19 +176,13 @@ impl HttpClient for HttpClientWithProxy {
}
/// An [`HttpClient`] that has a base URL.
#[derive(Deref)]
pub struct HttpClientWithUrl {
base_url: Mutex<String>,
#[deref]
client: HttpClientWithProxy,
}
impl std::ops::Deref for HttpClientWithUrl {
type Target = HttpClientWithProxy;
fn deref(&self) -> &Self::Target {
&self.client
}
}
impl HttpClientWithUrl {
/// Returns a new [`HttpClientWithUrl`] with the given base URL.
pub fn new(
@@ -314,10 +302,6 @@ impl HttpClient for HttpClientWithUrl {
self.client.proxy.as_ref()
}
fn type_name(&self) -> &'static str {
self.client.type_name()
}
#[cfg(feature = "test-support")]
fn as_fake(&self) -> &FakeHttpClient {
self.client.as_fake()
@@ -384,10 +368,6 @@ impl HttpClient for BlockedHttpClient {
None
}
fn type_name(&self) -> &'static str {
type_name::<Self>()
}
#[cfg(feature = "test-support")]
fn as_fake(&self) -> &FakeHttpClient {
panic!("called as_fake on {}", type_name::<Self>())
@@ -482,10 +462,6 @@ impl HttpClient for FakeHttpClient {
None
}
fn type_name(&self) -> &'static str {
type_name::<Self>()
}
fn as_fake(&self) -> &FakeHttpClient {
self
}
+1 -5
View File
@@ -1,6 +1,6 @@
use std::error::Error;
use std::sync::{LazyLock, OnceLock};
use std::{any::type_name, borrow::Cow, mem, pin::Pin, task::Poll, time::Duration};
use std::{borrow::Cow, mem, pin::Pin, task::Poll, time::Duration};
use anyhow::anyhow;
use bytes::{BufMut, Bytes, BytesMut};
@@ -215,10 +215,6 @@ impl http_client::HttpClient for ReqwestClient {
self.proxy.as_ref()
}
fn type_name(&self) -> &'static str {
type_name::<Self>()
}
fn user_agent(&self) -> Option<&HeaderValue> {
self.user_agent.as_ref()
}