Created
June 6, 2021 17:56
-
-
Save devsnek/9a047c13d4357a47721c2adc19a7704c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const http = require('http'); | |
const http2 = require('http2'); | |
const req = http.get('http://nghttp2.org/httpbin/get', { | |
headers: { | |
'Connection': 'Upgrade, HTTP2-Settings', | |
'Upgrade': 'h2c', | |
'HTTP2-Settings': http2.getPackedSettings().toString('base64'), | |
}, | |
}); | |
req.once('upgrade', (r, socket, h) => { | |
const session = http2.connect('http://nghttp2.org', { | |
createConnection: () => socket, | |
}); | |
const req = session.request({ | |
':path': '/httpbin/get', | |
':method': 'GET', | |
}); | |
req.once('response', console.log); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment