Skip to content

Commit 61c8734

Browse files
committed
[fix test] handle proxy error since we are properly aborting the proxy Request
1 parent 77a1cff commit 61c8734

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Diff for: test/lib-http-proxy-test.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ describe('lib/http-proxy.js', function() {
7878
});
7979

8080
source.listen(ports.source);
81-
81+
8282
http.request({
8383
hostname: '127.0.0.1',
8484
port: ports.proxy,
8585
method: 'POST',
8686
headers: {
8787
'x-forwarded-for': '127.0.0.1'
88-
}
88+
}
8989
}, function() {}).end();
9090
});
9191
});
@@ -105,7 +105,7 @@ describe('lib/http-proxy.js', function() {
105105
});
106106

107107
source.listen(ports.source);
108-
108+
109109
http.request({
110110
hostname: '127.0.0.1',
111111
port: ports.proxy,
@@ -117,7 +117,7 @@ describe('lib/http-proxy.js', function() {
117117
expect(data.toString()).to.eql('Hello from ' + ports.source);
118118
});
119119

120-
res.on('end', function () {
120+
res.on('end', function () {
121121
source.close();
122122
proxy._server.close();
123123
done();
@@ -141,7 +141,7 @@ describe('lib/http-proxy.js', function() {
141141
})
142142

143143
proxy.listen(ports.proxy);
144-
144+
145145
http.request({
146146
hostname: '127.0.0.1',
147147
port: ports.proxy,
@@ -159,6 +159,11 @@ describe('lib/http-proxy.js', function() {
159159
timeout: 3
160160
}).listen(ports.proxy);
161161

162+
proxy.on('error', function (e) {
163+
expect(e).to.be.an(Error);
164+
expect(e.code).to.be.eql('ECONNRESET');
165+
});
166+
162167
var source = http.createServer(function(req, res) {
163168
setTimeout(function () {
164169
res.end('At this point the socket should be closed');
@@ -207,7 +212,7 @@ describe('lib/http-proxy.js', function() {
207212
// proxy.ee.on('http-proxy:**', function (uno, dos, tres) {
208213
// events.push(this.event);
209214
// })
210-
215+
211216
// http.request({
212217
// hostname: '127.0.0.1',
213218
// port: '8081',
@@ -314,4 +319,4 @@ describe('lib/http-proxy.js', function() {
314319
})
315320
});
316321
})
317-
});
322+
});

0 commit comments

Comments
 (0)