Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server forwards ping event from the transports Connection. #353

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/spdy/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Expand Down
8 changes: 8 additions & 0 deletions test/server-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down