From 567a19a6560e4b37b82b84fdfbe3456cdf97b5d5 Mon Sep 17 00:00:00 2001 From: Martin Algesten Date: Sun, 1 Jul 2018 09:04:50 +0200 Subject: [PATCH] resp.status() return u16 --- src/response.rs | 12 ++++++------ src/test/auth.rs | 4 ++-- src/test/range.rs | 6 +++--- src/test/simple.rs | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/response.rs b/src/response.rs index 384021d..09109ab 100644 --- a/src/response.rs +++ b/src/response.rs @@ -67,7 +67,7 @@ impl Response { /// ``` /// let resp = ureq::Response::new(401, "Authorization Required", "Please log in"); /// - /// assert_eq!(*resp.status(), 401); + /// assert_eq!(resp.status(), 401); /// ``` pub fn new(status: u16, status_text: &str, body: &str) -> Self { let r = format!("HTTP/1.1 {} {}\r\n\r\n{}\n", status, status_text, body); @@ -87,8 +87,8 @@ impl Response { } /// The status as a u16: `200` - pub fn status(&self) -> &u16 { - &self.status + pub fn status(&self) -> u16 { + self.status } /// The status text: `OK` @@ -171,7 +171,7 @@ impl Response { /// assert!(resp.error()); /// /// // synthetic error code 400 - /// assert_eq!(*resp.status(), 400); + /// assert_eq!(resp.status(), 400); /// /// // tell that it's synthetic. /// assert!(resp.synthetic()); @@ -379,7 +379,7 @@ impl Response { /// let read = Cursor::new(text.to_string().into_bytes()); /// let resp = ureq::Response::from_read(read); /// - /// assert_eq!(*resp.status(), 401); + /// assert_eq!(resp.status(), 401); /// ``` pub fn from_read(reader: impl Read) -> Self { Self::do_from_read(reader).unwrap_or_else(|e| e.into()) @@ -632,7 +632,7 @@ mod tests { let s = format!("HTTP/1.1 BORKED\r\n"); let resp: Response = s.parse::().unwrap_err().into(); assert_eq!(resp.http_version(), "HTTP/1.1"); - assert_eq!(*resp.status(), 500); + assert_eq!(resp.status(), 500); assert_eq!(resp.status_text(), "Bad Status"); assert_eq!(resp.content_type(), "text/plain"); let v = resp.into_string().unwrap(); diff --git a/src/test/auth.rs b/src/test/auth.rs index 719f205..7d3b228 100644 --- a/src/test/auth.rs +++ b/src/test/auth.rs @@ -14,7 +14,7 @@ fn basic_auth() { let resp = get("test://host/basic_auth") .auth("martin", "rubbermashgum") .call(); - assert_eq!(*resp.status(), 200); + assert_eq!(resp.status(), 200); } #[test] @@ -26,5 +26,5 @@ fn kind_auth() { let resp = get("test://host/kind_auth") .auth_kind("Digest", "abcdefgh123") .call(); - assert_eq!(*resp.status(), 200); + assert_eq!(resp.status(), 200); } diff --git a/src/test/range.rs b/src/test/range.rs index f548c15..a274316 100644 --- a/src/test/range.rs +++ b/src/test/range.rs @@ -7,7 +7,7 @@ fn read_range() { let resp = get("https://s3.amazonaws.com/foosrvr/bbb.mp4") .set("Range", "bytes=1000-1999") .call(); - assert_eq!(*resp.status(), 206); + assert_eq!(resp.status(), 206); let mut reader = resp.into_reader(); let mut buf = vec![]; let len = reader.read_to_end(&mut buf).unwrap(); @@ -26,7 +26,7 @@ fn agent_pool() { let resp = agent.get("https://s3.amazonaws.com/foosrvr/bbb.mp4") .set("Range", "bytes=1000-1999") .call(); - assert_eq!(*resp.status(), 206); + assert_eq!(resp.status(), 206); let mut reader = resp.into_reader(); let mut buf = vec![]; // reading the entire content will return the connection to the pool @@ -46,7 +46,7 @@ fn agent_pool() { let resp = agent.get("https://s3.amazonaws.com/foosrvr/bbb.mp4") .set("Range", "bytes=5000-6999") .call(); - assert_eq!(*resp.status(), 206); + assert_eq!(resp.status(), 206); let mut reader = resp.into_reader(); let mut buf = vec![]; let len = reader.read_to_end(&mut buf).unwrap(); diff --git a/src/test/simple.rs b/src/test/simple.rs index 1c8e10f..0867458 100644 --- a/src/test/simple.rs +++ b/src/test/simple.rs @@ -11,7 +11,7 @@ fn header_passing() { test::make_response(200, "OK", vec!["X-Bar: foo"], vec![]) }); let resp = get("test://host/header_passing").set("X-Foo", "bar").call(); - assert_eq!(*resp.status(), 200); + assert_eq!(resp.status(), 200); assert!(resp.has("X-Bar")); assert_eq!(resp.header("X-Bar").unwrap(), "foo"); } @@ -27,7 +27,7 @@ fn repeat_non_x_header() { .set("Accept", "bar") .set("Accept", "baz") .call(); - assert_eq!(*resp.status(), 200); + assert_eq!(resp.status(), 200); } #[test] @@ -45,7 +45,7 @@ fn repeat_x_header() { .set("X-Forwarded-For", "130.240.19.2") .set("X-Forwarded-For", "130.240.19.3") .call(); - assert_eq!(*resp.status(), 200); + assert_eq!(resp.status(), 200); } #[test]