2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-14 18:42:33 +03:00

Splitting progress event handlers into upload and download handlers

This commit is contained in:
Dylan Lundy
2016-08-23 14:22:59 +09:30
committed by Nick Uraltsev
parent 59080e68d9
commit 63f41b53aa
4 changed files with 127 additions and 10 deletions
+8 -6
View File
@@ -142,14 +142,16 @@ module.exports = function xhrAdapter(config) {
}
// Handle progress if needed
if (typeof config.progress === 'function') {
if (config.method === 'post' || config.method === 'put') {
request.upload.addEventListener('progress', config.progress);
} else if (config.method === 'get') {
request.addEventListener('progress', config.progress);
}
if (typeof config.onDownloadProgress === 'function') {
request.addEventListener('progress', config.onDownloadProgress);
}
// Not all browsers support upload events
if (typeof config.onUploadProgress === 'function' && request.upload) {
request.upload.addEventListener('progress', config.onUploadProgress);
}
if (requestData === undefined) {
requestData = null;
}