|
1 | 1 | /* eslint-disable no-prototype-builtins */ |
2 | 2 | /* 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 | +*/ |
3 | 30 | var parse = require('url').parse; |
4 | 31 | var events = require('events'); |
5 | 32 | var https = require('https'); |
@@ -107,6 +134,11 @@ function EventSource(url, eventSourceInitDict) { |
107 | 134 | options.createConnection = eventSourceInitDict.createConnection; |
108 | 135 | } |
109 | 136 |
|
| 137 | + // If specify agent, use it. |
| 138 | + if (eventSourceInitDict && eventSourceInitDict.agent !== undefined) { |
| 139 | + options.agent = eventSourceInitDict.agent; |
| 140 | + } |
| 141 | + |
110 | 142 | // If specify http proxy, make the request to sent to the proxy server, |
111 | 143 | // and include the original url in path and Host headers |
112 | 144 | var useProxy = eventSourceInitDict && eventSourceInitDict.proxy; |
|
0 commit comments