nodejs/http2

How do I get http2 session ?

yosuke-furukawa opened this issue · 1 comments

I would like to write some tests about http2 session, but I don't understand how to get the session from http2 server.

according to implementation guide, we have the following example codes.

const session = getSessionSomehow();
const socket = getSocketSomehow();
session.on('send', (buffer) => socket.write(buffer));

if the API does not exist yet, I will send other PR.

  • Version:
  • Platform:
  • Subsystem:
    http2

I have got it!

  const server = http2.createServer();
  server.on('stream', (stream, headers, flags) => {
    stream.respond({
      'content-type': 'text/html',
      ':status': 200
    });
    stream.end('test');
    stream.session; // this getter method can get session instance.
  });

thanks!