-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a `Http2Session` event whenever a non-ack `PING` is received. Fixes: #18514 Backport-PR-URL: #22850 PR-URL: #23009 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Denys Otrishko <[email protected]>
- Loading branch information
1 parent
ca933ce
commit 10576d6
Showing
5 changed files
with
82 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict'; | ||
|
||
const { | ||
hasCrypto, | ||
mustCall, | ||
skip | ||
} = require('../common'); | ||
if (!hasCrypto) | ||
skip('missing crypto'); | ||
|
||
const { | ||
deepStrictEqual | ||
} = require('assert'); | ||
const { | ||
createServer, | ||
connect | ||
} = require('http2'); | ||
|
||
const check = Buffer.from([ 1, 2, 3, 4, 5, 6, 7, 8 ]); | ||
|
||
const server = createServer(); | ||
server.on('stream', mustCall((stream) => { | ||
stream.respond(); | ||
stream.end('ok'); | ||
})); | ||
server.on('session', mustCall((session) => { | ||
session.on('ping', mustCall((payload) => { | ||
deepStrictEqual(check, payload); | ||
})); | ||
session.ping(check, mustCall()); | ||
})); | ||
server.listen(0, mustCall(() => { | ||
const client = connect(`http://localhost:${server.address().port}`); | ||
|
||
client.on('ping', mustCall((payload) => { | ||
deepStrictEqual(check, payload); | ||
})); | ||
client.on('connect', mustCall(() => { | ||
client.ping(check, mustCall()); | ||
})); | ||
|
||
const req = client.request(); | ||
req.resume(); | ||
req.on('close', mustCall(() => { | ||
client.close(); | ||
server.close(); | ||
})); | ||
})); |