-
-
Save orient-man/cc14924bb31ec46462b5 to your computer and use it in GitHub Desktop.
Temporary hack to set Content-Type response header for JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -157,6 +157,10 @@ | |
} else { | |
this.responseXML = mockHandler.responseXML; | |
} | |
+ } else if (typeof mockHandler.responseText == 'object') { | |
+ // since 1.9 responseText type has to match contentType | |
+ mockHandler.contentType = 'application/json'; | |
+ this.responseText = JSON.stringify(mockHandler.responseText); | |
} else { | |
this.responseText = mockHandler.responseText; | |
} | |
@@ -250,8 +254,12 @@ | |
return mockHandler.contentType || 'text/plain'; | |
} | |
}, | |
- getAllResponseHeaders: function() { | |
- var headers = ''; | |
+ getAllResponseHeaders: function () { | |
+ var headers = ''; | |
+ // since 1.9 responseText type has to match contentType | |
+ if (mockHandler.contentType) { | |
+ mockHandler.headers['Content-Type'] = mockHandler.contentType; | |
+ } | |
$.each(mockHandler.headers, function(k, v) { | |
headers += k + ': ' + v + "\n"; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment