lib/sse-channel.js
function initializeConnection(opts) {
    opts.request.socket.setTimeout(0);
    opts.request.socket.setNoDelay(true);
    opts.request.socket.setKeepAlive(true);
    opts.response.writeHead(200, {
        'Content-Type': 'text/event-stream;charset=UTF-8',
        'Cache-Control': 'no-cache',
        'Connection': 'keep-alive'
    });

    opts.response.write(':ok\n\n');

    // Only set retry if it has a sane value
    var retry = opts.retry | 0;
    if (retry) {
        opts.response.write('retry: ' + retry + '\n');
    }

    // Should we delivar a "preamble" to the client? Required in some cases by Internet Explorer,
    // see https://github.com/amvtek/EventSource/wiki/UserGuide for more information
    if (opts.preamble) {
        opts.response.write(':' + preambleData);
    }

    flush(opts.response);
}
function initializeConnection(opts) {
    opts.request.socket.setTimeout(0);
    opts.request.socket.setNoDelay(true);
    opts.request.socket.setKeepAlive(true);
    opts.response.writeHead(200, {
        'Content-Type': 'text/event-stream;charset=UTF-8',
        'Cache-Control': 'no-cache',
        'Connection': 'keep-alive'
    });

    opts.response.write(':ok\n\n');

    // Only set retry if it has a sane value
    var retry = opts.retry | 0;
    if (retry) {
        opts.response.write('retry: ' + retry + '\n');
    }

    // Should we delivar a "preamble" to the client? Required in some cases by Internet Explorer,
    // see https://github.com/amvtek/EventSource/wiki/UserGuide for more information
    if (opts.preamble) {
        opts.response.write(':' + preambleData);
    }

    flush(opts.response);
}
function initializeConnection ( opts ) { opts . request . socket . setTimeout ( 0 ) ; opts . request . socket . setNoDelay ( true ) ; opts . request . socket . setKeepAlive ( true ) ; opts . response . writeHead ( 200 , { 'Content-Type' : 'text/event-stream;charset=UTF-8' , 'Cache-Control' : 'no-cache' , 'Connection' : 'keep-alive' } ) ; opts . response . write ( ':ok\n\n' ) ; // Only set retry if it has a sane value var retry = opts . retry | 0 ; if ( retry ) { opts . response . write ( 'retry: ' + retry + '\n' ) ; } // Should we delivar a "preamble" to the client? Required in some cases by Internet Explorer, // see https://github.com/amvtek/EventSource/wiki/UserGuide for more information if ( opts . preamble ) { opts . response . write ( ':' + preambleData ) ; } flush ( opts . response ) ; }
Sends the initial, required headers for the connection

@param {Object}   opts           Options object
@param {Request}  opts.request   Request object to use
@param {Response} opts.response  Response object to use
@param {Number}   opts.retry     Time in milliseconds to specify as reconnection timeout
@param {Boolean}  opts.preamble  Whether to send a "preamble" of dummy data to the client
Sends the initial required headers for the connection