Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. const http2 = require('http2');
  2. const fs = require('fs');
  3.  
  4. const server = http2.createSecureServer({
  5. key: fs.readFileSync('localhost-privkey.pem'),
  6. cert: fs.readFileSync('localhost-cert.pem')
  7. });
  8. server.on('error', (err) => console.error(err));
  9.  
  10. server.on('stream', (stream, headers) => {
  11. // stream is a Duplex
  12. stream.respond({
  13. 'content-type': 'text/html',
  14. ':status': 200
  15. });
  16. stream.end('<h1>Hello World</h1>');
  17. });
  18.  
  19. server.listen(8443);
  20.  
  21. Unknown ALPN Protocol, expected `h2` to be available.
  22. 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