diff options
author | Vincent Ambo <mail@tazj.in> | 2019-02-26T15·21+0100 |
---|---|---|
committer | Vincent Ambo <mail@tazj.in> | 2019-02-26T16·30+0100 |
commit | bd726c7d4c0b32af26d338e6c33f9fb8a7d80171 (patch) | |
tree | 4c5e4e276e7d9e761acdf075627428d64ec15145 /src/lib.rs | |
parent | 415e930a07d8c3ae481a2c9e9efc0f1ea938bd5f (diff) |
feat: Add Response::is_success utility method
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs index 56d6327e40bf..9caedff31914 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -303,6 +303,14 @@ impl <'a> Request<'a> { } } +impl <T> Response<T> { + /// Check whether the status code of this HTTP response is a + /// success (i.e. in the 200-299 range). + pub fn is_success(&self) -> bool { + self.status >= 200 && self.status < 300 + } +} + impl Response<Vec<u8>> { /// Attempt to parse the HTTP response body as a UTF-8 encoded /// string. |