Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use server-destory to close hanging sockets #2205

Merged
merged 1 commit into from May 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions tests/test-httpModule.js
Expand Up @@ -2,6 +2,7 @@

var http = require('http')
, https = require('https')
, destroyable = require('server-destroy')
, server = require('./server')
, request = require('../index')
, tape = require('tape')
Expand Down Expand Up @@ -36,6 +37,9 @@ var faux_http = wrap_request('http', http)
, plain_server = server.createServer()
, https_server = server.createSSLServer()

destroyable(plain_server)
destroyable(https_server)

tape('setup', function(t) {
plain_server.listen(plain_server.port, function() {
plain_server.on('/plain', function (req, res) {
Expand Down Expand Up @@ -100,8 +104,8 @@ run_tests('https only', { 'https:': faux_https })
run_tests('http and https', { 'http:': faux_http, 'https:': faux_https })

tape('cleanup', function(t) {
plain_server.close(function() {
https_server.close(function() {
plain_server.destroy(function() {
https_server.destroy(function() {
t.end()
})
})
Expand Down
8 changes: 6 additions & 2 deletions tests/test-redirect-auth.js
Expand Up @@ -4,10 +4,14 @@ var server = require('./server')
, request = require('../index')
, util = require('util')
, tape = require('tape')
, destroyable = require('server-destroy')

var s = server.createServer()
, ss = server.createSSLServer()

destroyable(s)
destroyable(ss)

// always send basic auth and allow non-strict SSL
request = request.defaults({
auth : {
Expand Down Expand Up @@ -117,8 +121,8 @@ runTest('different host and protocol',
false)

tape('cleanup', function(t) {
s.close(function() {
ss.close(function() {
s.destroy(function() {
ss.destroy(function() {
t.end()
})
})
Expand Down
8 changes: 6 additions & 2 deletions tests/test-redirect-complex.js
Expand Up @@ -4,11 +4,15 @@ var server = require('./server')
, request = require('../index')
, events = require('events')
, tape = require('tape')
, destroyable = require('server-destroy')

var s = server.createServer()
, ss = server.createSSLServer()
, e = new events.EventEmitter()

destroyable(s)
destroyable(ss)

function bouncy(s, serverUrl) {
var redirs = { a: 'b'
, b: 'c'
Expand Down Expand Up @@ -79,8 +83,8 @@ tape('lots of redirects', function(t) {
})

tape('cleanup', function(t) {
s.close(function() {
ss.close(function() {
s.destroy(function() {
ss.destroy(function() {
t.end()
})
})
Expand Down
8 changes: 6 additions & 2 deletions tests/test-redirect.js
Expand Up @@ -5,12 +5,16 @@ var server = require('./server')
, request = require('../index')
, tape = require('tape')
, http = require('http')
, destroyable = require('server-destroy')

var s = server.createServer()
, ss = server.createSSLServer()
, hits = {}
, jar = request.jar()

destroyable(s)
destroyable(ss)

s.on('/ssl', function(req, res) {
res.writeHead(302, {
location : ss.url + '/'
Expand Down Expand Up @@ -419,8 +423,8 @@ tape('should use same agent class on redirect', function(t) {
})

tape('cleanup', function(t) {
s.close(function() {
ss.close(function() {
s.destroy(function() {
ss.destroy(function() {
t.end()
})
})
Expand Down