Skip to content

Commit

Permalink
Fix Method::is_idempotent
Browse files Browse the repository at this point in the history
  • Loading branch information
XAMPPRocky authored and seanmonstar committed Dec 2, 2019
1 parent 4a5b64d commit 0cbcc1e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ impl Method {
/// more words.
pub fn is_idempotent(&self) -> bool {
match self.0 {
Put | Delete | _ if self.is_safe() => true,
_ => false
Put | Delete => true,
_ => self.is_safe(),
}
}

Expand Down Expand Up @@ -423,3 +423,17 @@ fn test_invalid_method() {
assert!(Method::from_str("").is_err());
assert!(Method::from_bytes(b"").is_err());
}

#[test]
fn test_is_idempotent() {
assert!(Method::OPTIONS.is_idempotent());
assert!(Method::GET.is_idempotent());
assert!(Method::PUT.is_idempotent());
assert!(Method::DELETE.is_idempotent());
assert!(Method::HEAD.is_idempotent());
assert!(Method::TRACE.is_idempotent());

assert!(!Method::POST.is_idempotent());
assert!(!Method::CONNECT.is_idempotent());
assert!(!Method::PATCH.is_idempotent());
}

0 comments on commit 0cbcc1e

Please sign in to comment.