新增数据传输结束时文件下载完成情况的判断

pull/96/head
lyswhut 2019-11-25 11:44:31 +08:00
parent cccfb6a08a
commit f2077dca04
1 changed files with 7 additions and 1 deletions

View File

@ -126,7 +126,13 @@ class Task extends EventEmitter {
response response
.on('data', this.__handleWriteData.bind(this)) .on('data', this.__handleWriteData.bind(this))
.on('error', err => this.__handleError(err)) .on('error', err => this.__handleError(err))
.on('end', () => this.__handleComplete()) .on('end', () => {
if (response.complete) {
this.__handleComplete()
} else {
this.__handleError(new Error('The connection was terminated while the message was still being sent'))
}
})
}) })
.on('error', err => this.__handleError(err)) .on('error', err => this.__handleError(err))
.on('close', () => this.__closeWriteStream()) .on('close', () => this.__closeWriteStream())