request .get(url.href) .on('response', (resp) => { resp.on('data', (chunk) => { if(image.size > MAX_FILE_SIZE + 1024*10) { // maxFileSize + 10KB padding. isMaxFileSizeExceed = true; .on('end', () => { if(isResponseSent) return; if(isMaxFileSizeExceed) .on('error', (err) => { log.error(err, 'Error uploading file'); return errors.internalServer(res); }) .on('finish', async () => { const metadata = await gcsFile.getMetadata(); await gcsFile.makePublic();
request(BASEURI + '/cgi-bin/snapshot.cgi?' + options.channel , function (error, response, body) { if ((error) || (response.statusCode !== 200)) { self.emit("error", 'ERROR ON SNAPSHOT'); } }) .on('end',function(){ if(TRACE) console.log('SNAPSHOT SAVED'); self.emit("getSnapshot", { 'status':'DONE',}); }) .auth(USER,PASS,false).pipe(fs.createWriteStream(path.join(options.path,options.filename)));
req.on('error', function(err) { if (queueItem.isChat && err.code === 'ETIMEDOUT') err = new DubAPIError('Chat request timed out'); that._.dubAPI.emit('error', err); //Will not work for chat request timeouts if (!queueItem.isRetry && ['ETIMEDOUT', 'ECONNRESET', 'ESOCKETTIMEDOUT'].indexOf(err.code) !== -1) { queueItem.isRetry = true; that._.queue.unshift(queueItem); if (!that._.ticking || queueItem.isChat) that._tick(); return; } if (queueItem.isChat) that._tick(); });
req.on('response', function (res) { var stream = this; if (res.statusCode != 200) { self._log.error(group, 'bad status code'); return self._done(); } stream.pipe(parser); });
require('request') .get(url) .on('error', (err) => { kuro.log(err) _msg.edit(`***Error:*** ${err}`) }) .pipe(fs.createWriteStream(dest))
app.all('/model/:route', function(req, res) { req.pipe(request(args.model + req.path)) .on('error', function(err) { console.error(err); res.status(500).send('Error connecting to the model microservice'); }) .pipe(res); });
req.on('complete', function(res, body) { if (!queueItem.isRetry && res.statusCode === 302 && res.headers.location === '/auth/login') { that._.dubAPI._.actHandler.doLogin(function(err) { if (err) that._.dubAPI.emit('error', err); queueItem.isRetry = true; that._.queue.unshift(queueItem); if (!that._.ticking || queueItem.isChat) that._tick(); }); return; } if (queueItem.isChat) that._tick(); if (typeof queueItem.callback === 'function') queueItem.callback(res.statusCode, body); else if (res.statusCode !== 200) that._.dubAPI.emit('error', new DubAPIRequestError(res.statusCode, queueItem.options.url)); });
client.on('socket', function(socket) { // Set keep-alive probes - throws ESOCKETTIMEDOUT error after ~16min if connection broken NetKeepAlive.setKeepAliveInterval(socket, 1000); if (TRACE) console.log('TCP_KEEPINTVL:',NetKeepAlive.getKeepAliveInterval(socket)); NetKeepAlive.setKeepAliveProbes(socket, 1); if (TRACE) console.log('TCP_KEEPCNT:',NetKeepAlive.getKeepAliveProbes(socket)); });
app.get(/.*/, (req, res) => { request(`http://localhost:${config.portNumber}/`) .on("error", (err) => res.sendFile("loading.html", { root: __dirname })) .pipe(res); });
// something went wrong downloading the tarball? req.on('error', function (err) { if (err.code === 'ENOTFOUND') { return cb(new Error('This is most likely not a problem with node-gyp or the package itself and\n' + 'is related to network connectivity. In most cases you are behind a proxy or have bad \n' + 'network settings.')) } badDownload = true cb(err) })
req.on('response', (res) => { if(res.statusCode === 200) { urlPath = res.client._httpMessage._headers.host + res.client._httpMessage.path; resolve(urlPath); } });
req.on('close', function () { if (extractCount === 0) { cb(new Error('Connection closed while downloading tarball file')) } })
client.on('error', function(err) { handleDahuaEventError(self, err); });