Skip to content
This repository was archived by the owner on Jun 26, 2024. It is now read-only.

Commit

Permalink
Made request with query parameters to be correctly signed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kazuhiro Ogura committed Oct 23, 2011
1 parent f8ed576 commit 4de934c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/erlaws_s3.erl
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,9 @@ genericRequest( Method, Bucket, Path, QueryParams, Metadata,

Signature = sign(SecretAccessKey,
stringToSign(MethodString, ContentMD5, ContentType, Date,
Bucket, Path, Headers )),
Bucket,
Path ++ erlaws_util:queryParams(QueryParams),
Headers )),

FinalHeaders = [ {"Authorization","AWS " ++ AccessKey ++ ":" ++ Signature },
{"Host", buildHost(Bucket) },
Expand Down
13 changes: 11 additions & 2 deletions src/erlaws_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,17 @@ mkEnumeration(Values, Separator) ->

queryParams( [] ) -> "";
queryParams( ParamList ) ->
"?" ++ mkEnumeration([[url_encode(Param), "=", url_encode(Value)]
|| {Param, Value} <- ParamList], "&" ).
L0 = lists:foldl(fun({P, V}, Acc) ->
case V of
"" ->
[url_encode(P)|Acc];
_ ->
[url_encode(P) ++ "=" ++ url_encode(V)|Acc]
end
end,
[],
lists:keysort(1, ParamList)),
"?" ++ mkEnumeration(lists:reverse(L0), "&").

%% The following code is taken from the ibrowse Http client
%% library.
Expand Down

0 comments on commit 4de934c

Please sign in to comment.