expose responseType in download()
This commit is contained in:
parent
405400de68
commit
d035e18b9f
|
@ -417,6 +417,7 @@ function deleteStyleSafe({id, notify = true} = {}) {
|
||||||
function download(url, {
|
function download(url, {
|
||||||
method = url.includes('?') ? 'POST' : 'GET',
|
method = url.includes('?') ? 'POST' : 'GET',
|
||||||
body = url.includes('?') ? url.slice(url.indexOf('?')) : null,
|
body = url.includes('?') ? url.slice(url.indexOf('?')) : null,
|
||||||
|
responseType = 'text',
|
||||||
requiredStatusCode = 200,
|
requiredStatusCode = 200,
|
||||||
timeout = 10e3,
|
timeout = 10e3,
|
||||||
headers = {
|
headers = {
|
||||||
|
@ -444,12 +445,13 @@ function download(url, {
|
||||||
if (event.type !== 'error' && (
|
if (event.type !== 'error' && (
|
||||||
xhr.status === requiredStatusCode || !requiredStatusCode ||
|
xhr.status === requiredStatusCode || !requiredStatusCode ||
|
||||||
url.protocol === 'file:')) {
|
url.protocol === 'file:')) {
|
||||||
resolve(xhr.responseText);
|
resolve(xhr.response);
|
||||||
} else {
|
} else {
|
||||||
reject(xhr.status);
|
reject(xhr.status);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.onerror = xhr.onloadend;
|
xhr.onerror = xhr.onloadend;
|
||||||
|
xhr.responseType = responseType;
|
||||||
xhr.open(method, url.href, true);
|
xhr.open(method, url.href, true);
|
||||||
for (const key in headers) {
|
for (const key in headers) {
|
||||||
xhr.setRequestHeader(key, headers[key]);
|
xhr.setRequestHeader(key, headers[key]);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user