| Server IP : 185.208.173.17 / Your IP : 87.236.161.98 Web Server : Microsoft-IIS/10.0 System : Windows NT SRV8576125506 10.0 build 26100 (Windows Server 2016) AMD64 User : IUSR ( 0) PHP Version : 7.4.13 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/parsmega.nuxt/node_modules/http-shutdown/ |
Upload File : |
var http = require('http');
var httpShutdown = require('./index').extend();
var should = require('chai').should();
var request = require('request');
describe('http-shutdown', function(done) {
it('Should shutdown with no traffic', function(done) {
var server = http.createServer(function(req, res) {
done.fail();
}).withShutdown();
server.listen(16789, function() {
server.shutdown(function(err) {
should.not.exist(err);
done();
})
})
});
it('Should shutdown with outstanding traffic', function(done) {
var server = http.createServer(function(req, res) {
setTimeout(function() {
res.writeHead(200);
res.end('All done');
}, 500);
}).withShutdown();
server.listen(16789, function(err) {
request.get('http://localhost:16789/', function(err, response) {
should.not.exist(err);
response.statusCode.should.equal(200);
done();
});
setTimeout(server.shutdown, 100);
});
});
it('Should force shutdown without waiting for outstanding traffic', function(done) {
var server = http.createServer(function(req, res) {
setTimeout(function() {
done.fail();
}, 500);
}).withShutdown();
server.listen(16789, function(err) {
request.get('http://localhost:16789/', function(err, response) {
should.exist(err);
done();
});
setTimeout(server.forceShutdown, 100);
});
});
});