Skip to content

Commit

Permalink
moved to ibrowse
Browse files Browse the repository at this point in the history
  • Loading branch information
tsloughter committed Mar 22, 2012
1 parent 1d1508f commit 33259d1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{lager, ".*", {git, "git://github.com/basho/lager.git", {branch, "master"}}},
{jsx, ".*", {git, "git://github.com/talentdeficit/jsx.git", {branch, "master"}}},
{mochiweb, ".*", {git, "git://github.com/mochi/mochiweb.git", {branch, "master"}}},
{lhttpc, ".*", {git, "git://github.com/oscarh/lhttpc.git", {branch, "master"}}}
{ibrowse, ".*", {git, "git://github.com/tsloughter/ibrowse", {branch, "master"}}}
]}.

{require_otp_vsn, "R14|R15"}.
Expand Down
7 changes: 2 additions & 5 deletions src/ddb.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
stdlib,
lager,
crypto,
inets,
ssl
ssl,
ibrowse
]},
{agner, [
{requires, ["lager"]}
]},
{env, []}
]}.
4 changes: 2 additions & 2 deletions src/ddb.erl
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ update_action('delete') -> <<"DELETE">>.
request(Target, JSON) ->
Body = jsx:to_json(JSON),
Headers = headers(Target, Body),
Opts = [{'body_format', 'binary'}],
F = fun() -> httpc:request('post', {?DDB_ENDPOINT, Headers, ?CONTENT_TYPE, Body}, [], Opts) end,
Opts = [{'response_format', 'binary'}],
F = fun() -> ibrowse:request(?DDB_ENDPOINT, [{'Content-type', ?CONTENT_TYPE} | Headers], 'post', Body, Opts) end,
ddb_aws:retry(F, ?MAX_RETRIES, fun jsx:to_term/1).

-spec headers(string(), binary()) -> proplists:proplist().
Expand Down
6 changes: 4 additions & 2 deletions src/ddb_iam.erl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

-export([credentials/2, token/1]).

-include_lib("ibrowse/include/ibrowse.hrl").

-define(IAM_ENDPOINT, "https://sts.amazonaws.com/").
-define(IAM_AWS_VERSION, "2011-06-15").
-define(IAM_HEADER_AUTHORIZATION, "Authorization").
Expand Down Expand Up @@ -86,12 +88,12 @@ request(Action, Endpoint, Duration) ->
{"Timestamp", ddb_aws:timestamp()},
{"Version", ?IAM_AWS_VERSION}],
CanonicalString = mochiweb_util:urlencode(lists:sort(Args)),
{Host, _Port, Path, _SSL} = lhttpc_lib:parse_url(Endpoint),
#url{host=Host, path=Path} = ibrowse:parse_url(Endpoint),
S = ["POST", $\n, Host, $\n, Path, $\n, CanonicalString],
Signature = base64:encode_to_string(crypto:sha_mac(SecretAccessKey, S)),
Args1 = [{"Signature", Signature}|Args],
Body = iolist_to_binary(mochiweb_util:urlencode(lists:sort(Args1))),
F = fun() -> httpc:request('post', {Endpoint, [], ?MIME_TYPE, Body}, [], []) end,
F = fun() -> ibrowse:send_req(Endpoint, [{'Content-type', ?MIME_TYPE}], 'post', Body, []) end,
H = fun ddb_xml:parse/1,
ddb_aws:retry(F, ?IAM_MAX_RETRIES, H).

0 comments on commit 33259d1

Please sign in to comment.