diff --git a/examples/json.rs b/examples/json.rs index a9ba31e3..68b391b1 100644 --- a/examples/json.rs +++ b/examples/json.rs @@ -6,6 +6,8 @@ //! isahc = { version = "*", features = ["json"]} //! ``` +#![allow(dead_code)] + use isahc::{prelude::*, Request}; #[derive(Debug, serde::Serialize)] diff --git a/src/config/dial.rs b/src/config/dial.rs index 6d7293bb..875e5823 100644 --- a/src/config/dial.rs +++ b/src/config/dial.rs @@ -134,7 +134,7 @@ impl FromStr for Dialer { if s.starts_with("unix:") { // URI paths are always absolute. let mut path = std::path::PathBuf::from("/"); - path.push(&s[5..].trim_start_matches('/')); + path.push(s[5..].trim_start_matches('/')); return Ok(Self(Inner::UnixSocket(path))); } diff --git a/src/cookies/jar.rs b/src/cookies/jar.rs index 46b92d64..f8484229 100644 --- a/src/cookies/jar.rs +++ b/src/cookies/jar.rs @@ -13,7 +13,7 @@ use std::{ #[derive(Clone, Debug)] pub struct CookieRejectedError { kind: CookieRejectedErrorKind, - cookie: Cookie, + cookie: Box, } /// The reason why the [`Cookie`] was rejected. @@ -35,6 +35,13 @@ pub enum CookieRejectedErrorKind { } impl CookieRejectedError { + fn new(kind: CookieRejectedErrorKind, cookie: Cookie) -> Self { + Self { + kind, + cookie: Box::new(cookie), + } + } + /// Get the kind of error that occurred. pub fn kind(&self) -> CookieRejectedErrorKind { self.kind @@ -42,7 +49,7 @@ impl CookieRejectedError { /// Get back the [`Cookie`] that failed to be set. pub fn cookie(self) -> Cookie { - self.cookie + *self.cookie } } @@ -138,10 +145,10 @@ impl CookieJar { "cookie '{}' dropped, no domain specified in request URI", cookie.name() ); - return Err(CookieRejectedError { - kind: CookieRejectedErrorKind::InvalidRequestDomain, + return Err(CookieRejectedError::new( + CookieRejectedErrorKind::InvalidRequestDomain, cookie, - }); + )); }; // Perform some validations on the domain. @@ -155,10 +162,10 @@ impl CookieJar { request_host, domain ); - return Err(CookieRejectedError { - kind: CookieRejectedErrorKind::DomainMismatch, + return Err(CookieRejectedError::new( + CookieRejectedErrorKind::DomainMismatch, cookie, - }); + )); } // Drop cookies for top-level domains. @@ -168,10 +175,10 @@ impl CookieJar { cookie.name(), domain ); - return Err(CookieRejectedError { - kind: CookieRejectedErrorKind::InvalidCookieDomain, + return Err(CookieRejectedError::new( + CookieRejectedErrorKind::InvalidCookieDomain, cookie, - }); + )); } // Check the PSL for bad domain suffixes if available. @@ -184,10 +191,10 @@ impl CookieJar { cookie.name(), domain ); - return Err(CookieRejectedError { - kind: CookieRejectedErrorKind::InvalidCookieDomain, + return Err(CookieRejectedError::new( + CookieRejectedErrorKind::InvalidCookieDomain, cookie, - }); + )); } } } diff --git a/src/handler.rs b/src/handler.rs index f1abe25a..10b40280 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -167,7 +167,7 @@ impl RequestHandler { let mut easy = Easy2::new(handler); easy.get_mut().handle = easy.raw(); let id = easy.get_ref().id(); - easy.get_mut().span.record("id", &id); + easy.get_mut().span.record("id", id); (easy, future) }