diff --git a/lib/spdy/server.js b/lib/spdy/server.js index 1889fcd..64eb3ec 100644 --- a/lib/spdy/server.js +++ b/lib/spdy/server.js @@ -124,6 +124,13 @@ proto._handleConnection = function _handleConnection (socket, protocol) { connection.start(2) } + // Pass the `ping` event to the server's EventEmitter as` _ping`. Pass the + // socket as an argument to the `_ping` event to allow identifying the + // connection that the ping was emitted from. + connection.on('ping', function () { + self.emit('_ping', socket) + }) + connection.on('error', function () { socket.destroy() }) diff --git a/test/server-test.js b/test/server-test.js index e743055..12e9885 100644 --- a/test/server-test.js +++ b/test/server-test.js @@ -138,6 +138,14 @@ describe('SPDY Server', function () { } }) + it('server should emit _ping event', function (done) { + server.once('_ping', function (socket) { + assert(socket instanceof net.Socket) + done() + }) + client.ping() + }) + it('should process expect-continue request', function (done) { var stream = client.request({ method: 'GET',