diff --git a/sentry/Cargo.toml b/sentry/Cargo.toml index 934c93ba1..54a982a48 100644 --- a/sentry/Cargo.toml +++ b/sentry/Cargo.toml @@ -51,8 +51,6 @@ release-health = ["sentry-core/release-health"] transport = ["reqwest", "native-tls"] reqwest = ["dep:reqwest", "httpdate", "tokio"] curl = ["dep:curl", "httpdate"] -surf-h1 = ["surf/h1-client", "httpdate"] -surf = ["surf/curl-client", "http-client", "httpdate", "isahc", "tokio"] ureq = ["dep:ureq", "httpdate"] # transport settings native-tls = ["dep:native-tls", "reqwest?/default-tls", "ureq?/native-tls"] @@ -79,9 +77,6 @@ reqwest = { version = "0.12", optional = true, features = [ ], default-features = false } curl = { version = "0.4.25", optional = true } httpdate = { version = "1.0.0", optional = true } -surf = { version = "2.0.0", optional = true, default-features = false } -http-client = { version = "6.5.3", optional = true } -isahc = { version = "0.9.14", optional = true } serde_json = { version = "1.0.48", optional = true } tokio = { version = "1.44", features = ["rt"], optional = true } ureq = { version = "2.10.1", optional = true, default-features = false } diff --git a/sentry/README.md b/sentry/README.md index 1e90b154e..9da99f0b5 100644 --- a/sentry/README.md +++ b/sentry/README.md @@ -81,7 +81,6 @@ extra setup to function properly. | `native-tls` | ✅ | | | `reqwest` must be enabled. | | `rustls` | | | | `reqwest` must be enabled. `native-tls` must be disabled via `default-features = false`. | | `curl` | | | | | -| `surf` | | | | | | `tower` | | 🔌 | | Requires extra setup; See [`sentry-tower`]'s documentation. | | `ureq` | | | | `ureq` transport support using `rustls` by default | | `ureq-native-tls` | | | | | @@ -113,7 +112,6 @@ extra setup to function properly. feature, and `default-features = false` must be set to completely disable building `native-tls` dependencies. - `curl`: Enables the `curl` transport. -- `surf`: Enables the `surf` transport. - `ureq`: Enables the `ureq` transport using `rustls`. - `ureq-native-tls`: Enables the `ureq` transport using `native-tls`. diff --git a/sentry/src/lib.rs b/sentry/src/lib.rs index 6652e1800..be98796ff 100644 --- a/sentry/src/lib.rs +++ b/sentry/src/lib.rs @@ -73,7 +73,6 @@ //! | `native-tls` | ✅ | | | `reqwest` must be enabled. | //! | `rustls` | | | | `reqwest` must be enabled. `native-tls` must be disabled via `default-features = false`. | //! | `curl` | | | | | -//! | `surf` | | | | | //! | `tower` | | 🔌 | | Requires extra setup; See [`sentry-tower`]'s documentation. | //! | `ureq` | | | | `ureq` transport support using `rustls` by default | //! | `ureq-native-tls` | | | | | @@ -105,7 +104,6 @@ //! feature, and `default-features = false` must be set to completely disable building `native-tls` //! dependencies. //! - `curl`: Enables the `curl` transport. -//! - `surf`: Enables the `surf` transport. //! - `ureq`: Enables the `ureq` transport using `rustls`. //! - `ureq-native-tls`: Enables the `ureq` transport using `native-tls`. //! diff --git a/sentry/src/transports/mod.rs b/sentry/src/transports/mod.rs index 46a849880..424c8a7a9 100644 --- a/sentry/src/transports/mod.rs +++ b/sentry/src/transports/mod.rs @@ -1,7 +1,7 @@ //! The provided transports. //! //! This module exposes all transports that are compiled into the sentry -//! library. The `reqwest`, `curl`, `surf` and `ureq` features turn on these transports. +//! library. The `reqwest`, `curl`, and `ureq` features turn on these transports. use crate::{ClientOptions, Transport, TransportFactory}; use std::sync::Arc; @@ -10,7 +10,7 @@ use std::sync::Arc; mod ratelimit; #[cfg(any(feature = "curl", feature = "ureq"))] mod thread; -#[cfg(any(feature = "reqwest", feature = "surf",))] +#[cfg(feature = "reqwest")] mod tokio_thread; #[cfg(feature = "reqwest")] @@ -28,11 +28,6 @@ mod curl; #[cfg(feature = "curl")] pub use self::curl::CurlHttpTransport; -#[cfg(feature = "surf")] -mod surf; -#[cfg(feature = "surf")] -pub use self::surf::SurfHttpTransport; - #[cfg(feature = "ureq")] mod ureq; #[cfg(feature = "ureq")] @@ -45,26 +40,15 @@ type DefaultTransport = ReqwestHttpTransport; feature = "curl", not(all(target_os = "espidf", feature = "embedded-svc-http")), not(feature = "reqwest"), - not(feature = "surf"), not(feature = "ureq") ))] type DefaultTransport = CurlHttpTransport; -#[cfg(all( - feature = "surf", - not(all(target_os = "espidf", feature = "embedded-svc-http")), - not(feature = "reqwest"), - not(feature = "curl"), - not(feature = "ureq") -))] -type DefaultTransport = SurfHttpTransport; - #[cfg(all( feature = "ureq", not(all(target_os = "espidf", feature = "embedded-svc-http")), not(feature = "reqwest"), not(feature = "curl"), - not(feature = "surf") ))] type DefaultTransport = UreqHttpTransport; @@ -73,7 +57,6 @@ type DefaultTransport = UreqHttpTransport; feature = "embedded-svc-http", not(feature = "reqwest"), not(feature = "curl"), - not(feature = "surf"), not(feature = "ureq") ))] type DefaultTransport = EmbeddedSVCHttpTransport; @@ -83,7 +66,6 @@ type DefaultTransport = EmbeddedSVCHttpTransport; all(target_os = "espidf", feature = "embedded-svc-http"), feature = "reqwest", feature = "curl", - feature = "surf", feature = "ureq" ))] pub type HttpTransport = DefaultTransport; @@ -102,7 +84,6 @@ impl TransportFactory for DefaultTransportFactory { all(target_os = "espidf", feature = "embedded-svc-http"), feature = "reqwest", feature = "curl", - feature = "surf", feature = "ureq" ))] { @@ -112,7 +93,6 @@ impl TransportFactory for DefaultTransportFactory { all(target_os = "espidf", feature = "embedded-svc-http"), feature = "reqwest", feature = "curl", - feature = "surf", feature = "ureq" )))] { diff --git a/sentry/src/transports/surf.rs b/sentry/src/transports/surf.rs deleted file mode 100644 index 0a902a688..000000000 --- a/sentry/src/transports/surf.rs +++ /dev/null @@ -1,102 +0,0 @@ -use std::time::Duration; - -use isahc::{ - config::{Configurable, SslOption}, - HttpClient, -}; -use surf::{http::headers as SurfHeaders, Client as SurfClient, StatusCode}; - -use super::tokio_thread::TransportThread; - -use crate::{sentry_debug, ClientOptions, Envelope, Transport}; - -/// A [`Transport`] that sends events via the [`surf`] library. -/// -/// This is enabled by the `surf` feature flag. -/// -/// [`surf`]: https://crates.io/crates/surf -#[cfg_attr(doc_cfg, doc(cfg(feature = "surf")))] -pub struct SurfHttpTransport { - thread: TransportThread, -} - -impl SurfHttpTransport { - /// Creates a new Transport. - pub fn new(options: &ClientOptions) -> Self { - Self::new_internal(options, None) - } - - /// Creates a new Transport that uses the specified [`SurfClient`]. - pub fn with_client(options: &ClientOptions, client: SurfClient) -> Self { - Self::new_internal(options, Some(client)) - } - - fn new_internal(options: &ClientOptions, client: Option) -> Self { - let mut client = client.unwrap_or_default(); - if options.accept_invalid_certs { - let hc = HttpClient::builder() - .ssl_options(SslOption::DANGER_ACCEPT_INVALID_CERTS) - .build() - .unwrap(); - let http_client = http_client::isahc::IsahcClient::from_client(hc); - client = SurfClient::with_http_client(http_client) - } - - let dsn = options.dsn.as_ref().unwrap(); - let user_agent = options.user_agent.clone(); - let auth = dsn.to_auth(Some(&user_agent)).to_string(); - let url = dsn.envelope_api_url().to_string(); - - let thread = TransportThread::new(move |envelope, mut rl| { - let mut body = Vec::new(); - envelope.to_writer(&mut body).unwrap(); - let request = client.post(&url).header("X-Sentry-Auth", &auth).body(body); - - async move { - match request.await { - Ok(mut response) => { - if let Some(sentry_header) = - response.header("x-sentry-rate-limits").map(|x| x.as_str()) - { - rl.update_from_retry_after(sentry_header); - } else if let Some(retry_after) = response - .header(SurfHeaders::RETRY_AFTER) - .map(|x| x.as_str()) - { - rl.update_from_retry_after(retry_after); - } else if response.status() == StatusCode::TooManyRequests { - rl.update_from_429(); - } - - match response.body_string().await { - Err(err) => { - sentry_debug!("Failed to read sentry response: {}", err); - } - Ok(text) => { - sentry_debug!("Get response: `{}`", text); - } - } - } - Err(err) => { - sentry_debug!("Failed to send envelope: {}", err); - } - } - rl - } - }); - Self { thread } - } -} - -impl Transport for SurfHttpTransport { - fn send_envelope(&self, envelope: Envelope) { - self.thread.send(envelope) - } - fn flush(&self, timeout: Duration) -> bool { - self.thread.flush(timeout) - } - - fn shutdown(&self, timeout: Duration) -> bool { - self.flush(timeout) - } -}