resp.destroy(); return errors.notFound(res); resp.destroy(); return errors.badRequest(res); resp.destroy(); return errors.unsupportedMediaType(res); if(image.size > MAX_FILE_SIZE + 1024*10) { // maxFileSize + 10KB padding. isMaxFileSizeExceed = true; resp.destroy(); // https://stackoverflow.com/questions/11761542
req.on('response', function(res) { res.setEncoding('utf8'); var responseData = ''; var status = res.statusCode; var headers = res.headers; res.on('data', function(chunk) { responseData += chunk; }); res.on('end', function() { res.destroy(); if (headers['content-type'] && headers['content-type'].indexOf('application/json') !== -1) { try { responseData = JSON.parse(responseData); } catch (error) { return done(error); } } done(null, responseData, status, headers); }); });
abort = true; response.destroy();
.on('response', (incoming) => { if (incoming.statusCode != 200) { return incoming.destroy({