新增于: v8.4.0
const http2 = require('node:http2');
const client = http2.connect('http://example.org:8000');
const { NGHTTP2_CANCEL } = http2.constants;
const req = client.request({ ':path': '/' });
req.setTimeout(5000, () => req.close(NGHTTP2_CANCEL));
Added in: v8.4.0
const http2 = require('node:http2');
const client = http2.connect('http://example.org:8000');
const { NGHTTP2_CANCEL } = http2.constants;
const req = client.request({ ':path': '/' });
req.setTimeout(5000, () => req.close(NGHTTP2_CANCEL));