File tree 1 file changed +16
-2
lines changed 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -207,8 +207,8 @@ impl Method {
207
207
/// more words.
208
208
pub fn is_idempotent ( & self ) -> bool {
209
209
match self . 0 {
210
- Put | Delete | _ if self . is_safe ( ) => true ,
211
- _ => false
210
+ Put | Delete => true ,
211
+ _ => self . is_safe ( ) ,
212
212
}
213
213
}
214
214
@@ -393,3 +393,17 @@ fn test_invalid_method() {
393
393
assert ! ( Method :: from_str( "" ) . is_err( ) ) ;
394
394
assert ! ( Method :: from_bytes( b"" ) . is_err( ) ) ;
395
395
}
396
+
397
+ #[ test]
398
+ fn test_is_idempotent ( ) {
399
+ assert ! ( Method :: OPTIONS . is_idempotent( ) ) ;
400
+ assert ! ( Method :: GET . is_idempotent( ) ) ;
401
+ assert ! ( Method :: PUT . is_idempotent( ) ) ;
402
+ assert ! ( Method :: DELETE . is_idempotent( ) ) ;
403
+ assert ! ( Method :: HEAD . is_idempotent( ) ) ;
404
+ assert ! ( Method :: TRACE . is_idempotent( ) ) ;
405
+
406
+ assert ! ( !Method :: POST . is_idempotent( ) ) ;
407
+ assert ! ( !Method :: CONNECT . is_idempotent( ) ) ;
408
+ assert ! ( !Method :: PATCH . is_idempotent( ) ) ;
409
+ }
You can’t perform that action at this time.
0 commit comments