@@ -45,11 +45,12 @@ validate_binding(_X, #binding{args = Args}) ->
45
45
case rabbit_misc :table_lookup (Args , <<" x-match" >>) of
46
46
{longstr , <<" all" >>} -> ok ;
47
47
{longstr , <<" any" >>} -> ok ;
48
+ {longstr , <<" all-with-x" >>} -> ok ;
48
49
{longstr , <<" any-with-x" >>} -> ok ;
49
50
{longstr , Other } -> {error ,
50
51
{binding_invalid ,
51
52
" Invalid x-match field value ~p ; "
52
- " expected all, any, or any-with-x" , [Other ]}};
53
+ " expected all, any, all-with-x, or any-with-x" , [Other ]}};
53
54
{Type , Other } -> {error ,
54
55
{binding_invalid ,
55
56
" Invalid x-match field type ~p (value ~p ); "
@@ -61,6 +62,7 @@ validate_binding(_X, #binding{args = Args}) ->
61
62
62
63
parse_x_match ({longstr , <<" all" >>}) -> all ;
63
64
parse_x_match ({longstr , <<" any" >>}) -> any ;
65
+ parse_x_match ({longstr , <<" all-with-x" >>}) -> all_with_x ;
64
66
parse_x_match ({longstr , <<" any-with-x" >>}) -> any_with_x ;
65
67
parse_x_match (_ ) -> all . % % legacy; we didn't validate
66
68
@@ -84,18 +86,25 @@ headers_match(Args, Data) ->
84
86
85
87
% A bit less horrendous algorithm :)
86
88
headers_match (_ , _ , false , _ , all ) -> false ;
89
+ headers_match (_ , _ , false , _ , all_with_x ) -> false ;
87
90
headers_match (_ , _ , _ , true , any ) -> true ;
88
91
headers_match (_ , _ , _ , true , any_with_x ) -> true ;
89
92
90
93
% No more bindings, return current state
91
94
headers_match ([], _Data , AllMatch , _AnyMatch , all ) -> AllMatch ;
95
+ headers_match ([], _Data , AllMatch , _AnyMatch , all_with_x ) -> AllMatch ;
92
96
headers_match ([], _Data , _AllMatch , AnyMatch , any ) -> AnyMatch ;
93
97
headers_match ([], _Data , _AllMatch , AnyMatch , any_with_x ) -> AnyMatch ;
94
98
95
- % Delete bindings starting with x-
99
+ % % Always delete binding x-match
100
+ headers_match ([{<<" x-match" >>, _PT , _PV } | PRest ], Data ,
101
+ AllMatch , AnyMatch , MatchKind ) ->
102
+ headers_match (PRest , Data , AllMatch , AnyMatch , MatchKind );
103
+ % Delete all other bindings starting with x-
104
+ % unless x-match is set to all-with-x or any-with-x
96
105
headers_match ([{<<" x-" , _ /binary >>, _PT , _PV } | PRest ], Data ,
97
106
AllMatch , AnyMatch , MatchKind )
98
- when MatchKind =/= any_with_x ->
107
+ when MatchKind =/= all_with_x , MatchKind =/= any_with_x ->
99
108
headers_match (PRest , Data , AllMatch , AnyMatch , MatchKind );
100
109
101
110
% No more data, but still bindings, false with all
0 commit comments