Browse Source

Fix oauth_client for missing content type response headers.

Tim Fletcher 15 years ago
parent
commit
e63269877d
1 changed files with 12 additions and 8 deletions
  1. 12 8
      src/oauth_client.erl

+ 12 - 8
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}