Skip to content

Commit 5f3878f

Browse files
lukebakkenmergify[bot]
authored andcommitted
Support string() or binary() as the body() type requires.
(cherry picked from commit 03f3e5b)
1 parent 717a873 commit 5f3878f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

deps/rabbitmq_aws/src/rabbitmq_aws_sign.erl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ headers(Request) ->
3030
{_, Host, _} = URI#uri.authority,
3131
Headers = append_headers(
3232
RequestTimestamp,
33-
length(Request#request.body),
33+
get_content_length(Request),
3434
PayloadHash,
3535
Host,
3636
Request#request.security_token,
@@ -313,3 +313,9 @@ string_to_sign(RequestTimestamp, RequestDate, Region, Service, RequestHash) ->
313313
%% @end
314314
sort_headers(Headers) ->
315315
lists:sort(fun({A, _}, {B, _}) -> string:to_lower(A) =< string:to_lower(B) end, Headers).
316+
317+
-spec get_content_length(Request :: #request{}) -> non_neg_integer().
318+
get_content_length(#request{body = Body}) when is_binary(Body) ->
319+
byte_size(Body);
320+
get_content_length(#request{body = Body}) when is_list(Body) ->
321+
length(Body).

0 commit comments

Comments
 (0)