diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2010-08-07 21:13:16 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2010-08-07 21:13:16 +0100 |
commit | 19e5b629dc24ff8669b582051909084db71c294b (patch) | |
tree | 8cadc4f6e9a8b9e4c44832c55b300b3c938ebe96 | |
parent | 4d70967753c17205159673c37680931dc25f5cfb (diff) | |
download | rabbitmq-server-19e5b629dc24ff8669b582051909084db71c294b.tar.gz |
no protocol in rabbit_binary_parser:ensure_content_decoded
it can just use the protocol associated with the #content, which is
safer and presents a saner API
-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 c1445a0c..d62fc07c 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 1d0a62af..b5ac4c66 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 6f244166..582960e7 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, |