You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
consthttp2=require('http2');constfs=require('fs');constserver=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 Duplexstream.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.
The text was updated successfully, but these errors were encountered:
You may have to visit with URL https://localhost:8443 (there may be a privacy error, since a self-signed certficate are used in the demo. You could trust the certificate temporarily to see what will happen).
I found on npm that the http2 module has been deprecated. Is it caused by this?
No, http2 is a built-in module of Node.js, and is not related to http2 on npm.
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.
The text was updated successfully, but these errors were encountered: