@@ -1468,6 +1468,11 @@ void Http2Session::HandleOriginFrame(const nghttp2_frame* frame) {
1468
1468
1469
1469
// Called by OnFrameReceived when a complete PING frame has been received.
1470
1470
inline void Http2Session::HandlePingFrame (const nghttp2_frame* frame) {
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;
1471
1476
bool ack = frame->hd .flags & NGHTTP2_FLAG_ACK;
1472
1477
if (ack) {
1473
1478
Http2Ping* ping = PopPing ();
@@ -1479,16 +1484,15 @@ inline void Http2Session::HandlePingFrame(const nghttp2_frame* frame) {
1479
1484
// receive an unsolicited PING ack on a connection. Either the peer
1480
1485
// is buggy or malicious, and we're not going to tolerate such
1481
1486
// nonsense.
1482
- Isolate* isolate = env ()->isolate ();
1483
- HandleScope scope (isolate);
1484
- Local<Context> context = env ()->context ();
1485
- Context::Scope context_scope (context);
1486
-
1487
- Local<Value> argv[1 ] = {
1488
- Integer::New (isolate, NGHTTP2_ERR_PROTO),
1489
- };
1490
- MakeCallback (env ()->error_string (), arraysize (argv), argv);
1487
+ arg = Integer::New (isolate, NGHTTP2_ERR_PROTO);
1488
+ MakeCallback (env ()->error_string (), 1 , &arg);
1491
1489
}
1490
+ } else {
1491
+ // Notify the session that a ping occurred
1492
+ arg = Buffer::Copy (env (),
1493
+ reinterpret_cast <const char *>(frame->ping .opaque_data ),
1494
+ 8 ).ToLocalChecked ();
1495
+ MakeCallback (env ()->onping_string (), 1 , &arg);
1492
1496
}
1493
1497
}
1494
1498
0 commit comments