Skip to content

Commit a365808

Browse files
Update eventsource to accept an agent option
1 parent 4053901 commit a365808

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/platform/getEventSource/eventsource.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
/* eslint-disable no-prototype-builtins */
22
/* eslint-disable no-restricted-syntax */
3+
/*
4+
Modified version of "eventsource" v1.1.2 package (https://www.npmjs.com/package/eventsource/v/1.1.2)
5+
that accepts a custom agent.
6+
7+
The MIT License
8+
9+
Copyright (c) EventSource GitHub organisation
10+
11+
Permission is hereby granted, free of charge, to any person obtaining
12+
a copy of this software and associated documentation files (the
13+
"Software"), to deal in the Software without restriction, including
14+
without limitation the rights to use, copy, modify, merge, publish,
15+
distribute, sublicense, and/or sell copies of the Software, and to
16+
permit persons to whom the Software is furnished to do so, subject to
17+
the following conditions:
18+
19+
The above copyright notice and this permission notice shall be
20+
included in all copies or substantial portions of the Software.
21+
22+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29+
*/
330
var parse = require('url').parse;
431
var events = require('events');
532
var https = require('https');
@@ -107,6 +134,11 @@ function EventSource(url, eventSourceInitDict) {
107134
options.createConnection = eventSourceInitDict.createConnection;
108135
}
109136

137+
// If specify agent, use it.
138+
if (eventSourceInitDict && eventSourceInitDict.agent !== undefined) {
139+
options.agent = eventSourceInitDict.agent;
140+
}
141+
110142
// If specify http proxy, make the request to sent to the proxy server,
111143
// and include the original url in path and Host headers
112144
var useProxy = eventSourceInitDict && eventSourceInitDict.proxy;

0 commit comments

Comments
 (0)