summaryrefslogtreecommitdiff
path: root/src/rabbit_binary_generator.erl
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2010-07-09 11:56:10 +0100
committerSimon MacMullen <simon@rabbitmq.com>2010-07-09 11:56:10 +0100
commit10bbf7e7bd0afb04ddf0bfc240b2f03f06c24283 (patch)
tree7c62275f592c0f0c47d1e63aabf44e55a576ba5a /src/rabbit_binary_generator.erl
parent02d0fa2f5d69b916bc62351a65b809b37c2324ed (diff)
downloadrabbitmq-server-10bbf7e7bd0afb04ddf0bfc240b2f03f06c24283.tar.gz
Store protocol with encoded properties, use it to transcode if needed.
Diffstat (limited to 'src/rabbit_binary_generator.erl')
-rw-r--r--src/rabbit_binary_generator.erl24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/rabbit_binary_generator.erl b/src/rabbit_binary_generator.erl
index 75cd643c..200bf2cd 100644
--- a/src/rabbit_binary_generator.erl
+++ b/src/rabbit_binary_generator.erl
@@ -82,18 +82,25 @@ build_simple_content_frames(ChannelInt,
#content{class_id = ClassId,
properties = ContentProperties,
properties_bin = ContentPropertiesBin,
+ protocol = ContentProtocol,
payload_fragments_rev = PayloadFragmentsRev},
FrameMax, Protocol) ->
{BodySize, ContentFrames} = build_content_frames(PayloadFragmentsRev, FrameMax, ChannelInt),
HeaderFrame = create_frame(2, ChannelInt,
[<<ClassId:16, 0:16, BodySize:64>>,
- maybe_encode_properties(ContentProperties, ContentPropertiesBin, Protocol)]),
+ maybe_encode_properties(ContentProperties,
+ ContentPropertiesBin,
+ ContentProtocol,
+ Protocol)]),
[HeaderFrame | ContentFrames].
-maybe_encode_properties(_ContentProperties, ContentPropertiesBin, _Protocol)
+maybe_encode_properties(_ContentProperties,
+ ContentPropertiesBin,
+ Protocol,
+ Protocol)
when is_binary(ContentPropertiesBin) ->
ContentPropertiesBin;
-maybe_encode_properties(ContentProperties, none, Protocol) ->
+maybe_encode_properties(ContentProperties, none, _ContentProtocol, Protocol) ->
Protocol:encode_properties(ContentProperties).
build_content_frames(FragsRev, FrameMax, ChannelInt) ->
@@ -278,13 +285,14 @@ check_empty_content_body_frame_size() ->
ComputedSize, ?EMPTY_CONTENT_BODY_FRAME_SIZE})
end.
-ensure_content_encoded(Content = #content{properties_bin = PropsBin}, _Protocol)
- when PropsBin =/= 'none' ->
+ensure_content_encoded(Content = #content{protocol = Protocol}, Protocol) ->
Content;
ensure_content_encoded(Content = #content{properties = Props}, Protocol) ->
- Content#content{properties_bin = Protocol:encode_properties(Props)}.
+ Content#content{properties_bin = Protocol:encode_properties(Props),
+ protocol = Protocol}.
-clear_encoded_content(Content = #content{properties_bin = none}) ->
+clear_encoded_content(Content = #content{properties_bin = none,
+ protocol = none}) ->
Content;
clear_encoded_content(Content = #content{properties = none}) ->
%% Only clear when we can rebuild the properties_bin later in
@@ -292,4 +300,4 @@ clear_encoded_content(Content = #content{properties = none}) ->
%% one of properties and properties_bin can be 'none'
Content;
clear_encoded_content(Content = #content{}) ->
- Content#content{properties_bin = none}.
+ Content#content{properties_bin = none, protocol = none}.