File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -220,8 +220,8 @@ impl Method {
220220 /// more words.
221221 pub fn is_idempotent ( & self ) -> bool {
222222 match self . 0 {
223- Put | Delete | _ if self . is_safe ( ) => true ,
224- _ => false
223+ Put | Delete => true ,
224+ _ => self . is_safe ( ) ,
225225 }
226226 }
227227
@@ -423,3 +423,17 @@ fn test_invalid_method() {
423423 assert ! ( Method :: from_str( "" ) . is_err( ) ) ;
424424 assert ! ( Method :: from_bytes( b"" ) . is_err( ) ) ;
425425}
426+
427+ #[ test]
428+ fn test_is_idempotent ( ) {
429+ assert ! ( Method :: OPTIONS . is_idempotent( ) ) ;
430+ assert ! ( Method :: GET . is_idempotent( ) ) ;
431+ assert ! ( Method :: PUT . is_idempotent( ) ) ;
432+ assert ! ( Method :: DELETE . is_idempotent( ) ) ;
433+ assert ! ( Method :: HEAD . is_idempotent( ) ) ;
434+ assert ! ( Method :: TRACE . is_idempotent( ) ) ;
435+
436+ assert ! ( !Method :: POST . is_idempotent( ) ) ;
437+ assert ! ( !Method :: CONNECT . is_idempotent( ) ) ;
438+ assert ! ( !Method :: PATCH . is_idempotent( ) ) ;
439+ }
You can’t perform that action at this time.
0 commit comments