Skip to content

Commit

Permalink
[fix test] handle proxy error since we are properly aborting the prox…
Browse files Browse the repository at this point in the history
…y Request
  • Loading branch information
jcrugzz committed Apr 14, 2014
1 parent 77a1cff commit 61c8734
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions test/lib-http-proxy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ describe('lib/http-proxy.js', function() {
});

source.listen(ports.source);

http.request({
hostname: '127.0.0.1',
port: ports.proxy,
method: 'POST',
headers: {
'x-forwarded-for': '127.0.0.1'
}
}
}, function() {}).end();
});
});
Expand All @@ -105,7 +105,7 @@ describe('lib/http-proxy.js', function() {
});

source.listen(ports.source);

http.request({
hostname: '127.0.0.1',
port: ports.proxy,
Expand All @@ -117,7 +117,7 @@ describe('lib/http-proxy.js', function() {
expect(data.toString()).to.eql('Hello from ' + ports.source);
});

res.on('end', function () {
res.on('end', function () {
source.close();
proxy._server.close();
done();
Expand All @@ -141,7 +141,7 @@ describe('lib/http-proxy.js', function() {
})

proxy.listen(ports.proxy);

http.request({
hostname: '127.0.0.1',
port: ports.proxy,
Expand All @@ -159,6 +159,11 @@ describe('lib/http-proxy.js', function() {
timeout: 3
}).listen(ports.proxy);

proxy.on('error', function (e) {
expect(e).to.be.an(Error);
expect(e.code).to.be.eql('ECONNRESET');
});

var source = http.createServer(function(req, res) {
setTimeout(function () {
res.end('At this point the socket should be closed');
Expand Down Expand Up @@ -207,7 +212,7 @@ describe('lib/http-proxy.js', function() {
// proxy.ee.on('http-proxy:**', function (uno, dos, tres) {
// events.push(this.event);
// })

// http.request({
// hostname: '127.0.0.1',
// port: '8081',
Expand Down Expand Up @@ -314,4 +319,4 @@ describe('lib/http-proxy.js', function() {
})
});
})
});
});

0 comments on commit 61c8734

Please sign in to comment.