@@ -1468,6 +1468,11 @@ void Http2Session::HandleOriginFrame(const nghttp2_frame* frame) {
14681468
14691469// Called by OnFrameReceived when a complete PING frame has been received.
14701470inline 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;
14711476 bool ack = frame->hd .flags & NGHTTP2_FLAG_ACK;
14721477 if (ack) {
14731478 Http2Ping* ping = PopPing ();
@@ -1479,16 +1484,15 @@ inline void Http2Session::HandlePingFrame(const nghttp2_frame* frame) {
14791484 // receive an unsolicited PING ack on a connection. Either the peer
14801485 // is buggy or malicious, and we're not going to tolerate such
14811486 // 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);
14911489 }
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);
14921496 }
14931497}
14941498
0 commit comments