@@ -1457,6 +1457,11 @@ void Http2Session::HandleOriginFrame(const nghttp2_frame* frame) {
1457
1457
1458
1458
// Called by OnFrameReceived when a complete PING frame has been received.
1459
1459
void Http2Session::HandlePingFrame (const nghttp2_frame* frame) {
1460
+ Isolate* isolate = env ()->isolate ();
1461
+ HandleScope scope (isolate);
1462
+ Local<Context> context = env ()->context ();
1463
+ Context::Scope context_scope (context);
1464
+ Local<Value> arg;
1460
1465
bool ack = frame->hd .flags & NGHTTP2_FLAG_ACK;
1461
1466
if (ack) {
1462
1467
Http2Ping* ping = PopPing ();
@@ -1468,13 +1473,15 @@ void Http2Session::HandlePingFrame(const nghttp2_frame* frame) {
1468
1473
// receive an unsolicited PING ack on a connection. Either the peer
1469
1474
// is buggy or malicious, and we're not going to tolerate such
1470
1475
// nonsense.
1471
- Isolate* isolate = env ()->isolate ();
1472
- HandleScope scope (isolate);
1473
- Local<Context> context = env ()->context ();
1474
- Context::Scope context_scope (context);
1475
- Local<Value> arg = Integer::New (isolate, NGHTTP2_ERR_PROTO);
1476
+ arg = Integer::New (isolate, NGHTTP2_ERR_PROTO);
1476
1477
MakeCallback (env ()->error_string (), 1 , &arg);
1477
1478
}
1479
+ } else {
1480
+ // Notify the session that a ping occurred
1481
+ arg = Buffer::Copy (env (),
1482
+ reinterpret_cast <const char *>(frame->ping .opaque_data ),
1483
+ 8 ).ToLocalChecked ();
1484
+ MakeCallback (env ()->onping_string (), 1 , &arg);
1478
1485
}
1479
1486
}
1480
1487
0 commit comments