Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

implement put

  • Loading branch information...
commit 9e556278033bc1b7087739b40f9c8f09dfbd71d0 1 parent f332b77
@rflynn rflynn authored
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/oauth.erl
View
12 src/oauth.erl
@@ -1,6 +1,6 @@
-module(oauth).
--export([get/3, get/5, get/6, post/3, post/5, post/6, uri/2, header/1,
+-export([get/3, get/5, get/6, post/3, post/5, post/6, put/6, put/7, uri/2, header/1,
sign/6, params_decode/1, token/1, token_secret/1, verify/6]).
-export([plaintext_signature/2, hmac_sha1_signature/5,
@@ -35,6 +35,13 @@ post(URL, ExtraParams, Consumer, Token, TokenSecret, HttpcOptions) ->
SignedParams = sign("POST", URL, ExtraParams, Consumer, Token, TokenSecret),
http_post(URL, uri_params_encode(SignedParams), HttpcOptions).
+put(URL, ExtraParams, {ContentType, Body}, Consumer, Token, TokenSecret) ->
+ put(URL, ExtraParams, {ContentType, Body}, Consumer, Token, TokenSecret, []).
+
+put(URL, ExtraParams, {ContentType, Body}, Consumer, Token, TokenSecret, HttpcOptions) ->
+ SignedParams = sign("PUT", URL, ExtraParams, Consumer, Token, TokenSecret),
+ http_put(uri(URL, SignedParams), [], {ContentType, Body}, HttpcOptions).
+
uri(Base, []) ->
Base;
uri(Base, Params) ->
@@ -179,6 +186,9 @@ http_get(URL, Options) ->
http_post(URL, Data, Options) ->
http_request(post, {URL, [], "application/x-www-form-urlencoded", Data}, Options).
+http_put(URL, Headers, {ContentType, Body}, Options) ->
+ http_request(put, {URL, Headers, ContentType, Body}, Options).
+
http_request(Method, Request, Options) ->
httpc:request(Method, Request, [{autoredirect, false}], Options).
Please sign in to comment.
Something went wrong with that request. Please try again.