use sentry_core::TransportOptions;
use crate::{Transport, TransportFactory};
use std::sync::Arc;
#[cfg(feature = "httpdate")]
mod ratelimit;
#[cfg(feature = "httpdate")]
pub use self::ratelimit::{RateLimiter, RateLimitingCategory};
#[cfg(any(feature = "curl", feature = "ureq"))]
mod thread;
#[cfg(any(feature = "curl", feature = "ureq"))]
pub use self::thread::{
TransportThread as StdTransportThread, TransportThreadOptions as StdTransportThreadOptions,
};
#[cfg(feature = "reqwest")]
mod tokio_thread;
#[cfg(feature = "reqwest")]
pub use self::tokio_thread::{
TransportThread as TokioTransportThread, TransportThreadOptions as TokioTransportThreadOptions,
};
#[cfg(feature = "reqwest")]
mod reqwest;
#[cfg(feature = "reqwest")]
pub use self::reqwest::{ReqwestHttpTransport, ReqwestHttpTransportOptions};
#[cfg(sentry_embedded_svc_http)]
mod embedded_svc_http;
#[cfg(sentry_embedded_svc_http)]
pub use self::embedded_svc_http::{EmbeddedSVCHttpTransport, EmbeddedSVCHttpTransportOptions};
#[cfg(feature = "curl")]
mod curl;
#[cfg(feature = "curl")]
pub use self::curl::{CurlHttpTransport, CurlHttpTransportOptions};
#[cfg(feature = "ureq")]
mod ureq;
#[cfg(feature = "ureq")]
pub use self::ureq::{UreqHttpTransport, UreqHttpTransportOptions};
#[cfg(sentry_any_http_transport)]
pub(crate) const HTTP_PAYLOAD_TOO_LARGE: u16 = 413;
#[cfg(sentry_any_http_transport)]
pub(crate) const HTTP_PAYLOAD_TOO_LARGE_MESSAGE: &str =
"Envelope was discarded due to size limits (HTTP 413).";
#[cfg(feature = "reqwest")]
type DefaultTransport = ReqwestHttpTransport;
#[cfg(all(
feature = "curl",
not(sentry_embedded_svc_http),
not(feature = "reqwest"),
not(feature = "ureq")
))]
type DefaultTransport = CurlHttpTransport;
#[cfg(all(
feature = "ureq",
not(sentry_embedded_svc_http),
not(feature = "reqwest"),
not(feature = "curl"),
))]
type DefaultTransport = UreqHttpTransport;
#[cfg(all(
sentry_embedded_svc_http,
not(feature = "reqwest"),
not(feature = "curl"),
not(feature = "ureq")
))]
type DefaultTransport = EmbeddedSVCHttpTransport;
#[cfg(sentry_any_http_transport)]
pub type HttpTransport = DefaultTransport;
#[derive(Clone)]
pub struct DefaultTransportFactory;
impl TransportFactory for DefaultTransportFactory {
fn create_transport_with_options(&self, options: TransportOptions) -> Arc<dyn Transport> {
#[cfg(sentry_any_http_transport)]
{
Arc::new(HttpTransport::with_options(options.into()))
}
#[cfg(not(sentry_any_http_transport))]
{
let _ = options;
panic!("sentry crate was compiled without transport")
}
}
}