Browse Source

Allow httpc options to be passed through.

Tim Fletcher 14 years ago
parent
commit
6b012def4e
2 changed files with 21 additions and 7 deletions
  1. 10 2
      src/oauth.erl
  2. 11 5
      src/oauth_http.erl

+ 10 - 2
src/oauth.erl

@@ -2,8 +2,10 @@
 
 
 -export(
 -export(
   [ get/5
   [ get/5
+  , get/6
   , header/1
   , header/1
   , post/5
   , post/5
+  , post/6
   , signature/5
   , signature/5
   , signature_base_string/3
   , signature_base_string/3
   , signed_params/6
   , 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, []).
+
+get(URL, ExtraParams, Consumer, Token, TokenSecret, HttpcOptions) ->
   SignedParams = signed_params("GET", URL, ExtraParams, Consumer, Token, TokenSecret),
   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, []).
+
+post(URL, ExtraParams, Consumer, Token, TokenSecret, HttpcOptions) ->
   SignedParams = signed_params("POST", URL, ExtraParams, Consumer, Token, TokenSecret),
   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, []) ->
 uri(Base, []) ->
   Base;
   Base;

+ 11 - 5
src/oauth_http.erl

@@ -1,16 +1,22 @@
 -module(oauth_http).
 -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) ->
 get(URL) ->
-  request(get, {URL, []}).
+  get(URL, []).
+
+get(URL, Options) ->
+  request(get, {URL, []}, Options).
 
 
 post(URL, Data) ->
 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) ->
 response_params(Response) ->
   oauth_uri:params_from_string(response_body(Response)).
   oauth_uri:params_from_string(response_body(Response)).