diff options
| -rw-r--r-- | src/rabbit_basic.erl | 5 | ||||
| -rw-r--r-- | src/rabbit_binary_parser.erl | 12 | ||||
| -rw-r--r-- | src/rabbit_channel.erl | 3 |
3 files changed, 9 insertions, 11 deletions
diff --git a/src/rabbit_basic.erl b/src/rabbit_basic.erl index c1445a0c69..d62fc07cb0 100644 --- a/src/rabbit_basic.erl +++ b/src/rabbit_basic.erl @@ -110,9 +110,8 @@ from_content(Content) -> #content{class_id = ClassId, properties = Props, payload_fragments_rev = FragmentsRev} = - %% basic.publish hasn't changed so we can just hard-code amqp_0_9_1 - rabbit_binary_parser:ensure_content_decoded(Content, - rabbit_framing_amqp_0_9_1), + rabbit_binary_parser:ensure_content_decoded(Content), + %% basic.publish hasn't changed so we can just hard-code amqp_0_9_1 {ClassId, _MethodId} = rabbit_framing_amqp_0_9_1:method_id('basic.publish'), {Props, list_to_binary(lists:reverse(FragmentsRev))}. diff --git a/src/rabbit_binary_parser.erl b/src/rabbit_binary_parser.erl index 1d0a62afe8..b5ac4c66e6 100644 --- a/src/rabbit_binary_parser.erl +++ b/src/rabbit_binary_parser.erl @@ -34,7 +34,7 @@ -include("rabbit.hrl"). -export([parse_table/1, parse_properties/2]). --export([ensure_content_decoded/2, clear_decoded_content/1]). +-export([ensure_content_decoded/1, clear_decoded_content/1]). -import(lists). @@ -45,9 +45,8 @@ -spec(parse_table/1 :: (binary()) -> rabbit_framing:amqp_table()). -spec(parse_properties/2 :: ([rabbit_framing:amqp_property_type()], binary()) -> [any()]). --spec(ensure_content_decoded/2 :: - (rabbit_types:content(), rabbit_types:protocol()) - -> rabbit_types:decoded_content()). +-spec(ensure_content_decoded/1 :: + (rabbit_types:content()) -> rabbit_types:decoded_content()). -spec(clear_decoded_content/1 :: (rabbit_types:content()) -> rabbit_types:undecoded_content()). @@ -163,10 +162,11 @@ parse_property(bit, Rest) -> parse_property(table, <<Len:32/unsigned, Table:Len/binary, Rest/binary>>) -> {parse_table(Table), Rest}. -ensure_content_decoded(Content = #content{properties = Props}, _Protocol) +ensure_content_decoded(Content = #content{properties = Props}) when Props =/= 'none' -> Content; -ensure_content_decoded(Content = #content{properties_bin = PropBin}, Protocol) +ensure_content_decoded(Content = #content{properties_bin = PropBin, + protocol = Protocol}) when is_binary(PropBin) -> Content#content{properties = Protocol:decode_properties( Content#content.class_id, PropBin)}. diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index 6f244166b5..582960e79d 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -421,8 +421,7 @@ handle_method(#'basic.publish'{exchange = ExchangeNameBin, Exchange = rabbit_exchange:lookup_or_die(ExchangeName), %% We decode the content's properties here because we're almost %% certain to want to look at delivery-mode and priority. - DecodedContent = rabbit_binary_parser:ensure_content_decoded( - Content, rabbit_framing_amqp_0_9_1), + DecodedContent = rabbit_binary_parser:ensure_content_decoded(Content), IsPersistent = is_message_persistent(DecodedContent), Message = #basic_message{exchange_name = ExchangeName, routing_key = RoutingKey, |
