Fix oauth_client for missing content type response headers.

Project: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/commit/e6326987
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/tree/e6326987
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/diff/e6326987

Branch: refs/heads/import
Commit: e63269877da54513436eb59cec0381e8843ba8da
Parents: 9d00161
Author: Tim Fletcher <[email protected]>
Authored: Sat Sep 26 15:01:16 2009 +0100
Committer: Tim Fletcher <[email protected]>
Committed: Sat Sep 26 15:01:16 2009 +0100

----------------------------------------------------------------------
 src/oauth_client.erl | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/e6326987/src/oauth_client.erl
----------------------------------------------------------------------
diff --git a/src/oauth_client.erl b/src/oauth_client.erl
index 4b50901..73a7869 100644
--- a/src/oauth_client.erl
+++ b/src/oauth_client.erl
@@ -110,14 +110,18 @@ handle_call({get, URL, Params, ParamsMethod}, _From, 
State={Consumer, _RParams,
     {ok, Response={{_, Status, _}, Headers, Body}} ->
       case Status of
         200 ->
-          ContentType = proplists:get_value("content-type", Headers, ""),
-          MediaType = hd(string:tokens(ContentType, ";")),
-          case lists:suffix("/xml", MediaType) orelse lists:suffix("+xml", 
MediaType) of
-            true ->
-              {XML, []} = xmerl_scan:string(Body),
-              {reply, {ok, Headers, XML}, State};
-            false ->
-              {reply, {ok, Headers, Body}, State}
+          case proplists:get_value("content-type", Headers) of
+            undefined ->
+              {reply, {ok, Headers, Body}, State};
+            ContentType ->
+              MediaType = hd(string:tokens(ContentType, ";")),
+              case lists:suffix("/xml", MediaType) orelse lists:suffix("+xml", 
MediaType) of
+                true ->
+                  {XML, []} = xmerl_scan:string(Body),
+                  {reply, {ok, Headers, XML}, State};
+                false ->
+                  {reply, {ok, Headers, Body}, State}
+              end
           end;
         _ ->
           {reply, Response, State}

Reply via email to