Permalink
Browse files

moved to ibrowse

  • Loading branch information...
1 parent 1d1508f commit 33259d1465714ec6a59313eac0766a20f445ec5d @tsloughter tsloughter committed Mar 22, 2012
Showing with 9 additions and 10 deletions.
  1. +1 −1 rebar.config
  2. +2 −5 src/ddb.app.src
  3. +2 −2 src/ddb.erl
  4. +4 −2 src/ddb_iam.erl
View
@@ -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"}.
View
@@ -11,11 +11,8 @@
stdlib,
lager,
crypto,
- inets,
- ssl
+ ssl,
+ ibrowse
]},
- {agner, [
- {requires, ["lager"]}
- ]},
{env, []}
]}.
View
@@ -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().
View
@@ -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).

0 comments on commit 33259d1

Please sign in to comment.