xhr.onload = () => {
if (xhr.readyState === XMLHttpRequest.DONE) {
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) {
- if (options.responseType && xhr.getResponseHeader("Content-Type")!.indexOf(options.responseType) !== 0) {
- // request succeeded but invalid response type
- this._failure(xhr, options);
- } else {
+ if (xhr.status === 204) {
+ // HTTP 204 does not contain a body, the `content-type` is undefined.
this._success(xhr, options);
+ } else {
+ if (options.responseType && xhr.getResponseHeader("Content-Type")!.indexOf(options.responseType) !== 0) {
+ // request succeeded but invalid response type
+ this._failure(xhr, options);
+ } else {
+ this._success(xhr, options);
+ }
}
} else {
this._failure(xhr, options);
}
}
- options.success(data!, xhr.responseText, xhr, options.data!);
+ options.success(data || {}, xhr.responseText, xhr, options.data!);
}
this._finalize(options);
xhr.onload = () => {
if (xhr.readyState === XMLHttpRequest.DONE) {
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) {
- if (options.responseType && xhr.getResponseHeader("Content-Type").indexOf(options.responseType) !== 0) {
- // request succeeded but invalid response type
- this._failure(xhr, options);
+ if (xhr.status === 204) {
+ // HTTP 204 does not contain a body, the `content-type` is undefined.
+ this._success(xhr, options);
}
else {
- this._success(xhr, options);
+ if (options.responseType && xhr.getResponseHeader("Content-Type").indexOf(options.responseType) !== 0) {
+ // request succeeded but invalid response type
+ this._failure(xhr, options);
+ }
+ else {
+ this._success(xhr, options);
+ }
}
}
else {
void new Promise((resolve_1, reject_1) => { require(["../BackgroundQueue"], resolve_1, reject_1); }).then(tslib_1.__importStar).then((backgroundQueue) => backgroundQueue.invoke());
}
}
- options.success(data, xhr.responseText, xhr, options.data);
+ options.success(data || {}, xhr.responseText, xhr, options.data);
}
this._finalize(options);
}