kopia lustrzana https://github.com/c9/core
fix parsing json response with charset
rodzic
d822cd5457
commit
69f1ae7f5a
|
@ -66,7 +66,7 @@ define(function(require, module, exports) {
|
|||
return done(new Error("Could not serialize body as json"));
|
||||
}
|
||||
}
|
||||
if (contentType.indexOf("application/x-www-form-urlencoded") === 0) {
|
||||
else if (contentType.indexOf("application/x-www-form-urlencoded") === 0) {
|
||||
body = qs.stringify(body);
|
||||
}
|
||||
else if (["[object File]", "[object Blob]"].indexOf(Object.prototype.toString.call(body)) > -1) {
|
||||
|
@ -75,7 +75,7 @@ define(function(require, module, exports) {
|
|||
}
|
||||
else {
|
||||
body = body.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var timer;
|
||||
|
@ -105,18 +105,15 @@ define(function(require, module, exports) {
|
|||
headers: parseHeaders(xhr.getAllResponseHeaders())
|
||||
};
|
||||
|
||||
var data;
|
||||
switch (options.overrideMimeType || res.headers["content-type"]) {
|
||||
case "application/json":
|
||||
try {
|
||||
data = JSON.parse(xhr.responseText);
|
||||
} catch (e) {
|
||||
return done(e);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
data = xhr.responseText;
|
||||
|
||||
var data = xhr.responseText;
|
||||
if ((options.overrideMimeType || res.headers["content-type"])
|
||||
.indexOf("application/json") === 0
|
||||
) {
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
} catch (e) {
|
||||
return done(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.status > 299) {
|
||||
|
|
Ładowanie…
Reference in New Issue