diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bc82ff0..4d3ee39a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,6 @@ # Unreleased * Body::content_length (#927) - * Body::discard() (#927) * Handle Authorization: Basic from URI (#923) * Remove many uses of Box::new() from Connector chain (#919) diff --git a/src/body/mod.rs b/src/body/mod.rs index 7dc61f60..eea3819a 100644 --- a/src/body/mod.rs +++ b/src/body/mod.rs @@ -1,5 +1,5 @@ use std::fmt; -use std::io::{self, Read}; +use std::io; use std::sync::Arc; pub use build::BodyBuilder; @@ -325,32 +325,6 @@ impl Body { let handler = self.source.into(); BodyWithConfig::new(handler, self.info.clone()) } - - /// Discards the body up to `max` bytes. - /// - /// This is useful if you want to discard the body without reading it. The connection - /// will be returned to the pool (if applicable) and ureq will be able to reuse it. - /// - /// If the body is bigger than `max`, the connection can't be reused and will be closed. - /// - /// Before calling this you can check the body size using [`Body::content_length()`]. However - /// if the body is chunked or close delimited, the size is unknown. - /// - /// # Example - /// - /// ``` - /// let (_, body) = ureq::get("http://httpbin.org/bytes/100") - /// .call()? - /// .into_parts(); - /// - /// // This discards up to 1000 bytes. - /// body.discard(1000)?; - /// # Ok::<_, ureq::Error>(()) - /// ``` - pub fn discard(mut self, max: u64) -> Result<(), Error> { - self.as_reader().discard(max)?; - Ok(()) - } } /// Configuration of how to read the body. @@ -632,19 +606,6 @@ impl<'a> BodyReader<'a> { pub(crate) fn body_mode(&self) -> BodyMode { self.outgoing_body_mode } - - fn discard(&mut self, max: u64) -> Result<(), Error> { - let mut buf = [0; 10 * 1024]; - let mut n = 0; - while n < max { - let read = self.reader.read(&mut buf)?; - if read == 0 { - break; - } - n += read as u64; - } - Ok(()) - } } #[allow(unused)]