Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var EventSource = function(request, response, options) {
this.writable = true;
options = options || {};
this._stream = response.socket;
this._ping = options.ping || this.DEFAULT_PING;
this._retry = options.retry || this.DEFAULT_RETRY;
var scheme = driver.isSecureRequest(request) ? 'https:' : 'http:';
this.url = scheme + '//' + request.headers.host + request.url;
this.lastEventId = request.headers['last-event-id'] || '';
this.readyState = API.CONNECTING;
var headers = new Headers(),
self = this;
if (options.headers) {
for (var key in options.headers) headers.set(key, options.headers[key]);
}
if (!this._stream || !this._stream.writable) return;
process.nextTick(function() { self._open() });
this._stream.setTimeout(0);
this._stream.setNoDelay(true);