Angular 7中的Http2客户端

问题描述 投票:0回答:1

我想在我的角度项目中将http2用于客户端。我使用“ npm install http2”命令安装了http2,并在http2-npm中使用了示例客户端代码。

但是,我得到警告以下

./ node_modules / http2 / lib / protocol / index.js 46:12-19中的警告

关键依赖项:require函数的使用方式依赖关系不能静态提取

页面上显示F12,控制台错误;

错误ReferenceError:未定义过程

at Object../node_modules/http2/lib/protocol/framer.js (framer.js:12)
at __webpack_require__ (bootstrap:79)
at Object../node_modules/http2/lib/protocol/endpoint.js (endpoint.js:3)
at __webpack_require__ (bootstrap:79)
at Object../node_modules/http2/lib/protocol/index.js (index.js:41)
at __webpack_require__ (bootstrap:79)
at Object../node_modules/http2/lib/http.js (http.js:136)
at __webpack_require__ (bootstrap:79)
at Object../node_modules/http2/lib/index.js (index.js:18)
at __webpack_require__ (bootstrap:79)

因此,我无法使用http2客户端从服务器获取数据。我该如何解决这些问题?

angular7 http2
1个回答
0
投票

您不需要客户端HTTP / 2的库。浏览器将自动使用HTTP / 2(服务器支持它),并使用HTTP / 1.1(如果不是)。

这是实现HTTP / 2的方式的一大优点-它基本上与JavaScript等更高级别的应用程序无缝连接。

当然,如果使用的是HTTP / 2,您可能会决定对应用程序进行不同的调整(例如,减少捆绑或推送),但是大多数情况下(最好是在服务器端处理)。

© www.soinside.com 2019 - 2024. All rights reserved.