Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Allow httpc options to be passed through.
  • Loading branch information
tim committed Nov 26, 2010
1 parent 24a39a2 commit 6b012def4e49d867e9255de26ef7273a3db27bd5
Showing 2 changed files with 21 additions and 7 deletions.
@@ -2,8 +2,10 @@

-export(
[ get/5
, get/6
, header/1
, post/5
, post/6
, signature/5
, signature_base_string/3
, signed_params/6
@@ -15,12 +17,18 @@


get(URL, ExtraParams, Consumer, Token, TokenSecret) ->
get(URL, ExtraParams, Consumer, Token, TokenSecret, []).

get(URL, ExtraParams, Consumer, Token, TokenSecret, HttpcOptions) ->
SignedParams = signed_params("GET", URL, ExtraParams, Consumer, Token, TokenSecret),
oauth_http:get(uri(URL, SignedParams)).
oauth_http:get(uri(URL, SignedParams), HttpcOptions).

post(URL, ExtraParams, Consumer, Token, TokenSecret) ->
post(URL, ExtraParams, Consumer, Token, TokenSecret, []).

post(URL, ExtraParams, Consumer, Token, TokenSecret, HttpcOptions) ->
SignedParams = signed_params("POST", URL, ExtraParams, Consumer, Token, TokenSecret),
oauth_http:post(URL, oauth_uri:params_to_string(SignedParams)).
oauth_http:post(URL, oauth_uri:params_to_string(SignedParams), HttpcOptions).

uri(Base, []) ->
Base;
@@ -1,16 +1,22 @@
-module(oauth_http).

-export([get/1, post/2, response_params/1, response_body/1, response_code/1]).
-export([get/1, get/2, post/2, post/3, response_params/1, response_body/1, response_code/1]).


get(URL) ->
request(get, {URL, []}).
get(URL, []).

get(URL, Options) ->
request(get, {URL, []}, Options).

post(URL, Data) ->
request(post, {URL, [], "application/x-www-form-urlencoded", Data}).
post(URL, Data, []).

post(URL, Data, Options) ->
request(post, {URL, [], "application/x-www-form-urlencoded", Data}, Options).

request(Method, Request) ->
httpc:request(Method, Request, [{autoredirect, false}], []).
request(Method, Request, Options) ->
httpc:request(Method, Request, [{autoredirect, false}], Options).

response_params(Response) ->
oauth_uri:params_from_string(response_body(Response)).

0 comments on commit 6b012de

Please sign in to comment.