// 重写Koa的listen方法
class KoaOnhttp2 extends Koa {
constructor() {
super()
}
listen(...args) {
debug('listen');
const server = http2.createServer(
keysOptions,
this.callback()
);
return server.listen(...args);
}
}
const app = new KoaOnhttp2();
下图中,同一个页面下的三个资源,Connection ID不同,分别建立了两条TCP链接
而下图,http2则使用了一条TCP链接就将资源全数返回