зеркало из https://github.com/mozilla/httpfs.git
Status code handling before parsing
This commit is contained in:
Родитель
7c79bd5442
Коммит
5592b2e94f
10
lib.js
10
lib.js
|
@ -89,7 +89,7 @@ exports.mount = function(endpoint, mountpoint, options, callback) {
|
|||
if (retries > 0) {
|
||||
delete call.request
|
||||
call.timer = setTimeout(() => {
|
||||
logDebug('sending (' + retries + 'left)', call.operation)
|
||||
logDebug('sending (' + retries + ' tries left)', call.operation)
|
||||
sendRequest(call, retries - 1)
|
||||
}, 1000)
|
||||
} else {
|
||||
|
@ -103,6 +103,10 @@ exports.mount = function(endpoint, mountpoint, options, callback) {
|
|||
let chunks = []
|
||||
res.on('data', chunk => chunks.push(chunk))
|
||||
res.on('end', () => {
|
||||
if (res.statusCode != 200) {
|
||||
logDebug('Status code ' + res.statusCode)
|
||||
return handleError(-70)
|
||||
}
|
||||
let result
|
||||
try {
|
||||
result = serializer.fromBuffer(Buffer.concat(chunks))
|
||||
|
@ -110,10 +114,6 @@ exports.mount = function(endpoint, mountpoint, options, callback) {
|
|||
logDebug('Problem parsing response buffer')
|
||||
return handleError(-70)
|
||||
}
|
||||
if (res.statusCode != 200) {
|
||||
logDebug('Status code ' + res.statusCode)
|
||||
return handleError(-70)
|
||||
}
|
||||
removeCall(call)
|
||||
call.callback.apply(null, result)
|
||||
})
|
||||
|
|
Загрузка…
Ссылка в новой задаче