阿西河

所有教程

公众号
🌙
阿西河前端的公众号

我的收藏

    最近访问  (文章)

      教程列表

      抓包专区
      测试专区

      Node.js http2 推送流到客户端

      Node.js http2 推送流到客户端

      To receive pushed streams on the client, set a listener for the ‘stream’ event on the ClientHttp2Session:

      const http2 = require('http2');
      
      const client = http2.connect('http://localhost');
      
      client.on('stream', (pushedStream, requestHeaders) => {
        pushedStream.on('push', (responseHeaders) => {
          // process response headers
        });
        pushedStream.on('data', (chunk) => { /* handle pushed data */ });
      });
      
      const req = client.request({ ':path': '/' });
      

      更多内容请参考:Node.js HTTP2,或者通过 点击对应菜单 进行查看;


      目录
      本文目录
      目录