diff --git a/rebar.config b/rebar.config index 8892e7e..551eefb 100644 --- a/rebar.config +++ b/rebar.config @@ -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"}. diff --git a/src/ddb.app.src b/src/ddb.app.src index 2ce6fbd..3f2d35e 100644 --- a/src/ddb.app.src +++ b/src/ddb.app.src @@ -11,11 +11,8 @@ stdlib, lager, crypto, - inets, - ssl + ssl, + ibrowse ]}, - {agner, [ - {requires, ["lager"]} - ]}, {env, []} ]}. diff --git a/src/ddb.erl b/src/ddb.erl index 416fc72..787cd87 100644 --- a/src/ddb.erl +++ b/src/ddb.erl @@ -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(). diff --git a/src/ddb_iam.erl b/src/ddb_iam.erl index 9989a4b..6869462 100644 --- a/src/ddb_iam.erl +++ b/src/ddb_iam.erl @@ -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"). @@ -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).