Skip to content

Commit

Permalink
Merge pull request #163 from aws-beam/expand-aws_request-sign_request…
Browse files Browse the repository at this point in the history
…-with-optional-encode-option

Add aws_request:sign_request/6 to allow individually generated modules from overriding the uri_encode_path option
  • Loading branch information
onno-vos-dev authored Jan 25, 2025
2 parents 103d20e + f18d797 commit 36b4ea3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/aws_request.erl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
, method_to_binary/1
, request/2
, sign_request/5
, sign_request/6
]).

-include_lib("hackney/include/hackney_lib.hrl").
Expand All @@ -23,6 +24,9 @@ request(RequestFun, Options) ->
%% Generate headers with an AWS signature version 4 for the specified
%% request.
sign_request(Client, Method, URL, Headers0, Body) ->
sign_request(Client, Method, URL, Headers0, Body, [{uri_encode_path, false}]).

sign_request(Client, Method, URL, Headers0, Body, Options) ->
AccessKeyID = aws_client:access_key_id(Client),
SecretAccessKey = aws_client:secret_access_key(Client),
Region = aws_client:region(Client),
Expand All @@ -32,7 +36,7 @@ sign_request(Client, Method, URL, Headers0, Body) ->
undefined -> Headers0;
_ -> [{<<"X-Amz-Security-Token">>, Token}|Headers0]
end,
aws_signature:sign_v4(AccessKeyID, SecretAccessKey, Region, Service, calendar:universal_time(), Method, URL, Headers, Body, [{uri_encode_path, false}]).
aws_signature:sign_v4(AccessKeyID, SecretAccessKey, Region, Service, calendar:universal_time(), Method, URL, Headers, Body, Options).

%% @doc Include additions only if they don't already exist in the provided list.
add_headers([], Headers) ->
Expand Down

0 comments on commit 36b4ea3

Please sign in to comment.