summaryrefslogtreecommitdiff
path: root/apps/oauth/src/oauth_http.erl
diff options
context:
space:
mode:
authorAdam Kocoloski <adam@cloudant.com>2010-08-11 15:34:41 -0400
committerAdam Kocoloski <adam@cloudant.com>2010-08-11 17:39:37 -0400
commit8138d70bb8c1de954c46b417ccd22964b6432965 (patch)
treef833623bbf690a3d4d5799b6492e1ac729bfc152 /apps/oauth/src/oauth_http.erl
parent1c9d5c118ace092e228f60359e2863da1d3b1bc7 (diff)
move oauth to rebar layout
Diffstat (limited to 'apps/oauth/src/oauth_http.erl')
-rw-r--r--apps/oauth/src/oauth_http.erl22
1 files changed, 22 insertions, 0 deletions
diff --git a/apps/oauth/src/oauth_http.erl b/apps/oauth/src/oauth_http.erl
new file mode 100644
index 00000000..bf5a4bac
--- /dev/null
+++ b/apps/oauth/src/oauth_http.erl
@@ -0,0 +1,22 @@
+-module(oauth_http).
+
+-export([get/1, post/2, response_params/1, response_body/1, response_code/1]).
+
+
+get(URL) ->
+ request(get, {URL, []}).
+
+post(URL, Data) ->
+ request(post, {URL, [], "application/x-www-form-urlencoded", Data}).
+
+request(Method, Request) ->
+ http:request(Method, Request, [{autoredirect, false}], []).
+
+response_params(Response) ->
+ oauth_uri:params_from_string(response_body(Response)).
+
+response_body({{_, _, _}, _, Body}) ->
+ Body.
+
+response_code({{_, Code, _}, _, _}) ->
+ Code.