version: v10.24.0、v14.17.6
System: Linux kunlun 4.19.0-17-amd64 nodejs/nodejs.org#1 SMP Debian 4.19.194-3 (2021-07-18) x86_64 GNU/Linux
Issue: HTTP/2
Url: https://nodejs.org/api/http2.html
describe
node/
├── package.json
├── public
├── src
│ └── server.js
└── ssl
├── localhost-cert.pem
└── localhost-privkey.pem
const http2 = require('http2');
const fs = require('fs');
const server = http2.createSecureServer({
key: fs.readFileSync('./ssl/localhost-privkey.pem'),
cert: fs.readFileSync('./ssl/localhost-cert.pem')
});
server.on('error', (err) => console.error(err));
server.on('stream', (stream, headers) => {
// stream is a Duplex
stream.respond({
'content-type': 'text/html; charset=utf-8',
':status': 200
});
stream.write('<h1>Hello,world!</h1>')
stream.end();
});
server.listen(8443);
I wrote it according to the example in the HTTP/2 document. It did not make a mistake, but when I visited localhost:8443, the browser returned: "localhost did not send any data."
I found on npm that the http2 module has been deprecated. Is it caused by this? Is there any alternative? Because I’m learning node recently, the HTTP2 described in the book supports multiplexing, header compression, service push and other features, which can reduce a lot of overhead, which is very important to me.
version: v10.24.0、v14.17.6
System: Linux kunlun 4.19.0-17-amd64 nodejs/nodejs.org#1 SMP Debian 4.19.194-3 (2021-07-18) x86_64 GNU/Linux
Issue: HTTP/2
Url: https://nodejs.org/api/http2.html
describe
I wrote it according to the example in the HTTP/2 document. It did not make a mistake, but when I visited localhost:8443, the browser returned: "localhost did not send any data."
I found on npm that the http2 module has been deprecated. Is it caused by this? Is there any alternative? Because I’m learning node recently, the HTTP2 described in the book supports multiplexing, header compression, service push and other features, which can reduce a lot of overhead, which is very important to me.