File tree 2 files changed +30
-0
lines changed
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,10 @@ function EventSource (url, eventSourceInitDict) {
98
98
// but for now exists as a backwards-compatibility layer
99
99
options . rejectUnauthorized = ! ( eventSourceInitDict && ! eventSourceInitDict . rejectUnauthorized )
100
100
101
+ if ( eventSourceInitDict && eventSourceInitDict . createConnection !== undefined ) {
102
+ options . createConnection = eventSourceInitDict . createConnection
103
+ }
104
+
101
105
// If specify http proxy, make the request to sent to the proxy server,
102
106
// and include the original url in path and Host headers
103
107
var useProxy = eventSourceInitDict && eventSourceInitDict . proxy
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ var fs = require('fs')
8
8
var mocha = require ( 'mocha' )
9
9
var assert = require ( 'assert' )
10
10
var u = require ( 'url' )
11
+ var net = require ( 'net' )
11
12
12
13
var it = mocha . it
13
14
var describe = mocha . describe
@@ -599,6 +600,31 @@ describe('HTTP Request', function () {
599
600
} )
600
601
} )
601
602
} )
603
+
604
+ it ( 'checks createConnection option' , function ( done ) {
605
+ createServer ( function ( err , server ) {
606
+ if ( err ) return done ( err )
607
+
608
+ var testResult = false
609
+
610
+ server . on ( 'request' , function ( ) {
611
+ assert . ok ( testResult )
612
+ server . close ( done )
613
+ } )
614
+
615
+ var urlObj = u . parse ( server . url )
616
+
617
+ new EventSource ( server . url , {
618
+ createConnection : function ( ) {
619
+ var connection = net . createConnection ( { port : urlObj . port , host : urlObj . hostname } )
620
+ connection . on ( 'connect' , function ( ) {
621
+ testResult = true
622
+ } )
623
+ return connection
624
+ }
625
+ } )
626
+ } )
627
+ } )
602
628
} )
603
629
604
630
describe ( 'HTTPS Support' , function ( ) {
You can’t perform that action at this time.
0 commit comments