--expose-http2flag支持实验性HTTP2支持.自2017年8月5日起,此标志可用于夜间构建(Node v8.4.0)(拉取请求).
node --expose-http2 client.js
Run Code Online (Sandbox Code Playgroud)
client.js
const http2 = require('http2');
const client = http2.connect('https://stackoverflow.com');
const req = client.request();
req.setEncoding('utf8');
req.on('response', (headers, flags) => {
console.log(headers);
});
let data = '';
req.on('data', (d) => data += d);
req.on('end', () => client.destroy());
req.end();
Run Code Online (Sandbox Code Playgroud)
--experimental-modules 也可以从Node v8.5.0添加flag.
node --expose-http2 --experimental-modules client.mjs
Run Code Online (Sandbox Code Playgroud)
client.mjs
import http2 from 'http2';
const client = http2.connect('https://stackoverflow.com');
Run Code Online (Sandbox Code Playgroud)
我使用NVS(节点版本切换器)来测试夜间构建.
nvs add nightly
nvs use nightly
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5691 次 |
| 最近记录: |