Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const http2 = require('http2');
- const fs = require('fs');
- const server = http2.createSecureServer({
- key: fs.readFileSync('localhost-privkey.pem'),
- cert: fs.readFileSync('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',
- ':status': 200
- });
- stream.end('<h1>Hello World</h1>');
- });
- server.listen(8443);
- Unknown ALPN Protocol, expected `h2` to be available.
- If this is a HTTP request: The server was not configured with the `allowHTTP1` option or a listener for the `unknownProtocol` event.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement