@@ -9,6 +9,8 @@ var http = require('http');
99var https = require ( 'https' ) ;
1010var assert = require ( 'assert' ) ;
1111var Proxy = require ( 'proxy' ) ;
12+ var Semver = require ( 'semver' ) ;
13+ var version = new Semver ( process . version ) ;
1214var HttpsProxyAgent = require ( '../' ) ;
1315
1416describe ( 'HttpsProxyAgent' , function ( ) {
@@ -204,36 +206,43 @@ describe('HttpsProxyAgent', function () {
204206 } ) ;
205207 } ) ;
206208 } ) ;
207- it ( 'should work over an HTTPS proxy' , function ( done ) {
208- // set HTTP "request" event handler for this test
209- sslServer . once ( 'request' , function ( req , res ) {
210- res . end ( JSON . stringify ( req . headers ) ) ;
211- } ) ;
212-
213- var proxy = process . env . HTTPS_PROXY || process . env . https_proxy || 'https://127.0.0.1:' + sslProxyPort ;
214- proxy = url . parse ( proxy ) ;
215- // `rejectUnauthorized` is actually necessary this time since the HTTPS
216- // proxy server itself is using a self-signed SSL certificate…
217- proxy . rejectUnauthorized = false ;
218- var agent = new HttpsProxyAgent ( proxy ) ;
219209
220- var opts = url . parse ( 'https://127.0.0.1:' + sslServerPort ) ;
221- opts . agent = agent ;
222- opts . rejectUnauthorized = false ;
210+ if ( version . compare ( '0.11.3' ) < 0 ) {
211+ // This test is disabled on node >= 0.11.3, since it currently segfaults :(
212+ // See: https://github.com/joyent/node/issues/6204
223213
224- https . get ( opts , function ( res ) {
225- var data = '' ;
226- res . setEncoding ( 'utf8' ) ;
227- res . on ( 'data' , function ( b ) {
228- data += b ;
214+ it ( 'should work over an HTTPS proxy' , function ( done ) {
215+ // set HTTP "request" event handler for this test
216+ sslServer . once ( 'request' , function ( req , res ) {
217+ res . end ( JSON . stringify ( req . headers ) ) ;
229218 } ) ;
230- res . on ( 'end' , function ( ) {
231- data = JSON . parse ( data ) ;
232- assert . equal ( '127.0.0.1:' + sslServerPort , data . host ) ;
233- done ( ) ;
219+
220+ var proxy = process . env . HTTPS_PROXY || process . env . https_proxy || 'https://127.0.0.1:' + sslProxyPort ;
221+ proxy = url . parse ( proxy ) ;
222+ // `rejectUnauthorized` is actually necessary this time since the HTTPS
223+ // proxy server itself is using a self-signed SSL certificate…
224+ proxy . rejectUnauthorized = false ;
225+ var agent = new HttpsProxyAgent ( proxy ) ;
226+
227+ var opts = url . parse ( 'https://127.0.0.1:' + sslServerPort ) ;
228+ opts . agent = agent ;
229+ opts . rejectUnauthorized = false ;
230+
231+ https . get ( opts , function ( res ) {
232+ var data = '' ;
233+ res . setEncoding ( 'utf8' ) ;
234+ res . on ( 'data' , function ( b ) {
235+ data += b ;
236+ } ) ;
237+ res . on ( 'end' , function ( ) {
238+ data = JSON . parse ( data ) ;
239+ assert . equal ( '127.0.0.1:' + sslServerPort , data . host ) ;
240+ done ( ) ;
241+ } ) ;
234242 } ) ;
235243 } ) ;
236- } ) ;
244+ }
245+
237246 } ) ;
238247
239248} ) ;
0 commit comments