@@ -126,7 +126,7 @@ describe('lib/http-proxy.js', function() {
126
126
done ( ) ;
127
127
} )
128
128
129
- var proxyServer = proxy . listen ( '8081' ) ;
129
+ proxy . listen ( '8081' ) ;
130
130
131
131
http . request ( {
132
132
hostname : '127.0.0.1' ,
@@ -136,6 +136,38 @@ describe('lib/http-proxy.js', function() {
136
136
} ) ;
137
137
} ) ;
138
138
139
+ describe ( '#createProxyServer setting the correct timeout value' , function ( ) {
140
+ it ( 'should hang up the socket at the timeout' , function ( done ) {
141
+ this . timeout ( 30 ) ;
142
+ var proxy = httpProxy . createProxyServer ( {
143
+ target : 'http://127.0.0.1:8080' ,
144
+ timeout : 3
145
+ } ) . listen ( '8081' ) ;
146
+
147
+ var source = http . createServer ( function ( req , res ) {
148
+ setTimeout ( function ( ) {
149
+ res . end ( 'At this point the socket should be closed' ) ;
150
+ } , 5 )
151
+ } ) ;
152
+
153
+ source . listen ( '8080' ) ;
154
+
155
+ var testReq = http . request ( {
156
+ hostname : '127.0.0.1' ,
157
+ port : '8081' ,
158
+ method : 'GET' ,
159
+ } , function ( ) { } ) ;
160
+
161
+ testReq . on ( 'error' , function ( e ) {
162
+ expect ( e ) . to . be . an ( Error ) ;
163
+ expect ( e . code ) . to . be . eql ( 'ECONNRESET' ) ;
164
+ done ( ) ;
165
+ } ) ;
166
+
167
+ testReq . end ( ) ;
168
+ } )
169
+ } )
170
+
139
171
// describe('#createProxyServer using the web-incoming passes', function () {
140
172
// it('should emit events correclty', function(done) {
141
173
// var proxy = httpProxy.createProxyServer({
@@ -244,3 +276,7 @@ describe('lib/http-proxy.js', function() {
244
276
} ) ;
245
277
} )
246
278
} ) ;
279
+
280
+ describe ( '#createProxyServer using the ws-incoming passes' , function ( ) {
281
+ it ( 'should call the callback with the error' ) ;
282
+ } )
0 commit comments