Permalink
Browse files

only include XML if the response was XML

  • Loading branch information...
1 parent cc5f1d0 commit 4bba140f7a7c37776499343c7f520f8dc65a8275 @bytespider bytespider committed Oct 1, 2011
Showing with 10 additions and 1 deletion.
  1. +10 −1 src/OAuth/Consumer.js
View
@@ -137,7 +137,16 @@
}
}
- var responseObject = {text: xhr.responseText, xml: xhr.responseXML || undefined, requestHeaders: requestHeaders, responseHeaders: responseHeaders};
+ var includeXML = false;
+ if ('Content-Type' in responseHeaders)
+ {
+ if (responseHeaders['Content-Type'] == 'text/xml')
+ {
+ includeXML = true;
+ }
+
+ }
+ var responseObject = {text: xhr.responseText, xml: (includeXML ? xhr.responseXML : ''), requestHeaders: requestHeaders, responseHeaders: responseHeaders};
// we are powerless against 3xx redirects
if((xhr.status >= 200 && xhr.status <= 226) || xhr.status == 304 || xhr.status === 0) {

0 comments on commit 4bba140

Please sign in to comment.