@@ -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
@@ -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,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()
}