Skip to content

Commit d41bc4c

Browse files
committed
fixup! fix amqpl usage
1 parent 8b1d4b3 commit d41bc4c

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

deps/rabbitmq_stomp/include/rabbit_stomp_frame.hrl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
%% Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
66
%%
77

8-
-record(stomp_frame, {command, headers, body_iolist}).
8+
-record(stomp_frame, {command, headers, body_iolist_rev}).

deps/rabbitmq_stomp/src/rabbit_stomp_frame.erl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ parse_body2(Content, Frame, Chunks, {more, Left}) ->
163163
more(fun(Rest) -> parse_body(Rest, Frame, Chunks1, Left) end);
164164
parse_body2(Content, Frame, Chunks, {done, Pos}) ->
165165
<<Chunk:Pos/binary, 0, Rest/binary>> = Content,
166-
Body = lists:reverse(finalize_chunk(Chunk, Chunks)),
167-
{ok, Frame#stomp_frame{body_iolist = Body}, Rest}.
166+
Body = finalize_chunk(Chunk, Chunks),
167+
{ok, Frame#stomp_frame{body_iolist_rev = Body}, Rest}.
168168

169169
finalize_chunk(<<>>, Chunks) -> Chunks;
170170
finalize_chunk(Chunk, Chunks) -> [Chunk | Chunks].
@@ -249,7 +249,7 @@ serialize(Frame, true) ->
249249
serialize(Frame, false) ++ [?LF];
250250
serialize(#stomp_frame{command = Command,
251251
headers = Headers,
252-
body_iolist = BodyFragments}, false) ->
252+
body_iolist_rev = BodyFragments}, false) ->
253253
Len = iolist_size(BodyFragments),
254254
[Command, ?LF,
255255
lists:map(fun serialize_header/1,
@@ -258,7 +258,10 @@ serialize(#stomp_frame{command = Command,
258258
Len > 0 -> [?HEADER_CONTENT_LENGTH ++ ":", integer_to_list(Len), ?LF];
259259
true -> []
260260
end,
261-
?LF, BodyFragments, 0].
261+
?LF, case BodyFragments of
262+
_ when is_binary(BodyFragments) -> BodyFragments;
263+
_ -> lists:reverse(BodyFragments)
264+
end, 0].
262265

263266
serialize_header({K, V}) when is_integer(V) -> hdr(escape(K), integer_to_list(V));
264267
serialize_header({K, V}) when is_boolean(V) -> hdr(escape(K), boolean_to_list(V));

deps/rabbitmq_stomp/src/rabbit_stomp_processor.erl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ maybe_clean_up_queue(Queue, #proc_state{auth_login = Username}) ->
791791
ok.
792792

793793
do_send(Destination, _DestHdr,
794-
Frame = #stomp_frame{body_iolist = BodyFragments},
794+
Frame = #stomp_frame{body_iolist_rev = BodyFragments},
795795
State0 = #proc_state{default_topic_exchange = DfltTopicEx,
796796
delivery_flow = Flow,
797797
user = User,
@@ -839,7 +839,7 @@ do_send(Destination, _DestHdr,
839839
properties = Props,
840840
properties_bin = none,
841841
protocol = none,
842-
payload_fragments_rev = [BodyFragments]
842+
payload_fragments_rev = BodyFragments
843843
},
844844

845845
Message0 = mc_amqpl:message(ExchangeName, RoutingKey, Content0),
@@ -1467,7 +1467,7 @@ ok(State) ->
14671467
ok(Command, Headers, BodyFragments, State) ->
14681468
{ok, #stomp_frame{command = Command,
14691469
headers = Headers,
1470-
body_iolist = BodyFragments}, State}.
1470+
body_iolist_rev = lists:reverse(BodyFragments)}, State}.
14711471

14721472
amqp_death(ErrorName, Explanation, State) when is_atom(ErrorName) ->
14731473
ErrorDesc = rabbit_misc:format("~ts", [Explanation]),
@@ -1507,11 +1507,11 @@ log_error(Message, Detail, ServerPrivateDetail) ->
15071507
send_frame(Command, Headers, BodyFragments, State) ->
15081508
send_frame(#stomp_frame{command = Command,
15091509
headers = Headers,
1510-
body_iolist = BodyFragments},
1510+
body_iolist_rev = BodyFragments},
15111511
State).
15121512

15131513
send_frame(Frame, State = #proc_state{send_fun = SendFun,
1514-
trailing_lf = TrailingLF}) ->
1514+
trailing_lf = TrailingLF}) ->
15151515
SendFun(rabbit_stomp_frame:serialize(Frame, TrailingLF)),
15161516
State.
15171517

@@ -1524,7 +1524,7 @@ send_error_frame(Message, ExtraHeaders, Detail, State) ->
15241524
{"content-type", "text/plain"},
15251525
{"version", string:join(?SUPPORTED_VERSIONS, ",")}] ++
15261526
ExtraHeaders,
1527-
Detail, State).
1527+
iolist_to_binary(Detail), State).
15281528

15291529
send_error(Message, Detail, State) ->
15301530
send_error_frame(Message, [], Detail, State).

deps/rabbitmq_stomp/test/frame_SUITE.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ parse_simple_frame_gen(Term) ->
5858
[?assertEqual({ok, Value},
5959
rabbit_stomp_frame:header(Frame, Key)) ||
6060
{Key, Value} <- Headers],
61-
#stomp_frame{body_iolist = Body} = Frame,
61+
#stomp_frame{body_iolist_rev = Body} = Frame,
6262
?assertEqual(<<"Body Content">>, iolist_to_binary(Body)).
6363

6464
parse_command_only(_) ->
@@ -113,7 +113,7 @@ parse_resume_mid_body(_) ->
113113
First = "COMMAND\n\nABC",
114114
Second = "DEF\0",
115115
{more, Resume} = parse(First),
116-
{ok, #stomp_frame{command = "COMMAND", body_iolist = Body}, _Rest} =
116+
{ok, #stomp_frame{command = "COMMAND", body_iolist_rev = Body}, _Rest} =
117117
parse(Second, Resume),
118118
?assertEqual([<<"ABC">>, <<"DEF">>], Body).
119119

@@ -145,7 +145,7 @@ no_nested_escapes(_) ->
145145
?assertEqual(Frame,
146146
#stomp_frame{command = "COM\\\\rAND",
147147
headers = [{"hdr\\rname", "hdr\\rval"}],
148-
body_iolist = []}).
148+
body_iolist_rev = []}).
149149

150150
header_name_with_cr(_) ->
151151
Content = "COMMAND\nhead\rer:val\n\n\0",
@@ -161,7 +161,7 @@ header_value_with_colon(_) ->
161161
?assertEqual(Frame,
162162
#stomp_frame{ command = "COMMAND",
163163
headers = [{"header", "val:ue"}],
164-
body_iolist = []}).
164+
body_iolist_rev = []}).
165165

166166
stream_offset_header(_) ->
167167
TestCases = [

0 commit comments

Comments
 (0)