summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmile Joubert <emile@rabbitmq.com>2013-05-09 17:23:33 +0100
committerEmile Joubert <emile@rabbitmq.com>2013-05-09 17:23:33 +0100
commit569b533d9dda176b5a38ebd7d166025444b83f43 (patch)
tree9089bb6a8f045133c765beba31ecd52a2923461b
parentcbb2d56b9f4e9c0f817f970dec53ec57d2513f3c (diff)
parentc0c9404e591a70ed87d13e3c5e8f3d10118e1c1f (diff)
downloadrabbitmq-server-569b533d9dda176b5a38ebd7d166025444b83f43.tar.gz
Merged stable into default
-rw-r--r--src/rabbit_exchange_type_headers.erl14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/rabbit_exchange_type_headers.erl b/src/rabbit_exchange_type_headers.erl
index cf2d3140..5b7f95fe 100644
--- a/src/rabbit_exchange_type_headers.erl
+++ b/src/rabbit_exchange_type_headers.erl
@@ -63,12 +63,14 @@ validate_binding(_X, #binding{args = Args}) ->
{binding_invalid,
"Invalid x-match field type ~p (value ~p); "
"expected longstr", [Type, Other]}};
- undefined -> {error,
- {binding_invalid, "x-match field missing", []}}
+ undefined -> ok %% [0]
end.
+%% [0] spec is vague on whether it can be omitted but in practice it's
+%% useful to allow people to do this
-parse_x_match(<<"all">>) -> all;
-parse_x_match(<<"any">>) -> any.
+parse_x_match({longstr, <<"all">>}) -> all;
+parse_x_match({longstr, <<"any">>}) -> any;
+parse_x_match(_) -> all. %% legacy; we didn't validate
%% Horrendous matching algorithm. Depends for its merge-like
%% (linear-time) behaviour on the lists:keysort
@@ -80,8 +82,8 @@ parse_x_match(<<"any">>) -> any.
%% !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
%%
headers_match(Args, Data) ->
- {longstr, MK} = rabbit_misc:table_lookup(Args, <<"x-match">>),
- headers_match(Args, Data, true, false, parse_x_match(MK)).
+ MK = parse_x_match(rabbit_misc:table_lookup(Args, <<"x-match">>)),
+ headers_match(Args, Data, true, false, MK).
headers_match([], _Data, AllMatch, _AnyMatch, all) ->
AllMatch;