From 9e270c77e8558f057ce0b36a18aeed6a9401ab85 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Sat, 5 Dec 2020 14:05:15 -0800 Subject: [PATCH] Remove error_on_non_2xx. After the recent changes in #257, it's probably not necessary. It's now quite easy to use a match statement to extract responses for certain status codes, or all status codes. --- src/request.rs | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/src/request.rs b/src/request.rs index 0394ad9..132458c 100644 --- a/src/request.rs +++ b/src/request.rs @@ -121,7 +121,7 @@ impl Request { let response = unit::connect(unit, true, 0, reader, false).map_err(|e| e.url(url.clone()))?; - if self.error_on_non_2xx && response.status() >= 400 { + if response.status() >= 400 { Err(Error::Status(response.status(), response)) } else { Ok(response) @@ -337,26 +337,6 @@ impl Request { .push((param.to_string(), value.to_string())); self } - - /// By default, if a response's status is anything but a 2xx or 3xx, - /// call()/send() and related methods will return an Error. If you want - /// to handle such responses as non-errors, set this to `false`. - /// - /// Example: - /// ``` - /// # fn main() -> Result<(), ureq::Error> { - /// # ureq::is_test(true); - /// let response = ureq::get("http://httpbin.org/status/500") - /// .error_on_non_2xx(false) - /// .call()?; - /// assert_eq!(response.status(), 500); - /// # Ok(()) - /// # } - /// ``` - pub fn error_on_non_2xx(mut self, value: bool) -> Self { - self.error_on_non_2xx = value; - self - } } #[test]