summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam Kocoloski <kocolosk@apache.org>2009-09-30 22:00:41 +0000
committerAdam Kocoloski <kocolosk@apache.org>2009-09-30 22:00:41 +0000
commit3c32073065286f57835323a7f97a3958a8021dec (patch)
tree174ac10dfb809863865edd4f80db12e589a46b7b /src
parent32f2b2260217bfc1f685274445eb7e1aea6a0199 (diff)
more OAuth fixes, in particular for requests with query-string parameters
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@820469 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_rep_httpc.erl18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/couchdb/couch_rep_httpc.erl b/src/couchdb/couch_rep_httpc.erl
index 35334225..b714be6b 100644
--- a/src/couchdb/couch_rep_httpc.erl
+++ b/src/couchdb/couch_rep_httpc.erl
@@ -26,18 +26,19 @@ do_request(#http_db{url=Url} = Req) when is_binary(Url) ->
do_request(Req) ->
#http_db{
auth = Auth,
+ body = B,
+ conn = Conn,
headers = Headers0,
method = Method,
- body = B,
options = Opts,
- conn = Conn
+ qs = QS
} = Req,
Url = full_url(Req),
Headers = case proplists:get_value(<<"oauth">>, Auth) of
undefined ->
Headers0;
{OAuthProps} ->
- [oauth_header(Url, Method, OAuthProps) | Headers0]
+ [oauth_header(Url, QS, Method, OAuthProps) | Headers0]
end,
Body = case B of
{Fun, InitialState} when is_function(Fun) ->
@@ -68,7 +69,7 @@ db_exists(Req, CanonicalUrl) ->
undefined ->
Headers0;
{OAuthProps} ->
- [oauth_header(Url, get, OAuthProps) | Headers0]
+ [oauth_header(Url, [], head, OAuthProps) | Headers0]
end,
case catch ibrowse:send_req(Url, Headers, head) of
{ok, "200", _, _} ->
@@ -177,7 +178,8 @@ maybe_decompress(Headers, Body) ->
Body
end.
-oauth_header(Url, Action, Props) ->
+oauth_header(Url, QS, Action, Props) ->
+ QSL = [{couch_util:to_list(K), couch_util:to_list(V)} || {K,V} <- QS],
ConsumerKey = ?b2l(proplists:get_value(<<"consumer_key">>, Props)),
Token = ?b2l(proplists:get_value(<<"token">>, Props)),
TokenSecret = ?b2l(proplists:get_value(<<"token_secret">>, Props)),
@@ -186,7 +188,9 @@ oauth_header(Url, Action, Props) ->
Method = case Action of
get -> "GET";
post -> "POST";
- put -> "PUT"
+ put -> "PUT";
+ head -> "HEAD"
end,
- Params = oauth:signed_params(Method, Url, [], Consumer, Token, TokenSecret),
+ Params = oauth:signed_params(Method, Url, QSL, Consumer, Token, TokenSecret)
+ -- QSL,
{"Authorization", "OAuth " ++ oauth_uri:params_to_header_string(Params)}.