Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

re: #12: implement PUT #13

Merged
merged 1 commit into from

2 participants

@rflynn

A vanilla implementation of PUT, with the params in the querystring.

@tim tim merged commit 690f093 into tim:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 12, 2012
  1. @rflynn

    implement put

    rflynn authored
This page is out of date. Refresh to see the latest.
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).
Something went wrong with that request. Please try again.