@@ -565,7 +565,7 @@ fn get_hashtag(key: &[u8]) -> Option<&[u8]> {
565
565
}
566
566
}
567
567
568
- #[ derive( Debug , Clone , Copy ) ]
568
+ #[ derive( Debug , Clone , Copy , PartialEq ) ]
569
569
enum RoutingInfo {
570
570
AllNodes ,
571
571
AllMasters ,
@@ -619,7 +619,7 @@ impl RoutingInfo {
619
619
b"XGROUP" | b"XINFO" => get_arg ( & args, 2 ) . and_then ( RoutingInfo :: for_key) ,
620
620
b"XREAD" | b"XREADGROUP" => {
621
621
let streams_position = args. iter ( ) . position ( |a| match a {
622
- Value :: Data ( a) => a == b"STREAMS" ,
622
+ Value :: Data ( a) => a. eq_ignore_ascii_case ( b"STREAMS" ) ,
623
623
_ => false ,
624
624
} ) ?;
625
625
get_arg ( & args, streams_position + 1 ) . and_then ( RoutingInfo :: for_key)
@@ -744,12 +744,34 @@ fn get_slots(connection: &mut Connection) -> RedisResult<Vec<Slot>> {
744
744
745
745
#[ cfg( test) ]
746
746
mod tests {
747
- use super :: get_hashtag;
747
+ use super :: { cmd , get_hashtag, RoutingInfo } ;
748
748
749
749
#[ test]
750
750
fn test_get_hashtag ( ) {
751
751
assert_eq ! ( get_hashtag( & b"foo{bar}baz" [ ..] ) , Some ( & b"bar" [ ..] ) ) ;
752
752
assert_eq ! ( get_hashtag( & b"foo{}{baz}" [ ..] ) , None ) ;
753
753
assert_eq ! ( get_hashtag( & b"foo{{bar}}zap" [ ..] ) , Some ( & b"{bar" [ ..] ) ) ;
754
754
}
755
+
756
+ #[ test]
757
+ fn test_routing_info_mixed_capatalization ( ) {
758
+ let mut upper = cmd ( "XREAD" ) ;
759
+ upper. arg ( "STREAMS" ) . arg ( "foo" ) . arg ( 0 ) ;
760
+
761
+ let mut lower = cmd ( "xread" ) ;
762
+ lower. arg ( "streams" ) . arg ( "foo" ) . arg ( 0 ) ;
763
+
764
+ assert_eq ! (
765
+ RoutingInfo :: for_packed_command( & upper. get_packed_command( ) ) . unwrap( ) ,
766
+ RoutingInfo :: for_packed_command( & lower. get_packed_command( ) ) . unwrap( )
767
+ ) ;
768
+
769
+ let mut mixed = cmd ( "xReAd" ) ;
770
+ mixed. arg ( "StReAmS" ) . arg ( "foo" ) . arg ( 0 ) ;
771
+
772
+ assert_eq ! (
773
+ RoutingInfo :: for_packed_command( & lower. get_packed_command( ) ) . unwrap( ) ,
774
+ RoutingInfo :: for_packed_command( & mixed. get_packed_command( ) ) . unwrap( )
775
+ ) ;
776
+ }
755
777
}
0 commit comments