Last active
September 7, 2020 16:47
-
-
Save joeyguerra/e55102c543cf30a13e14c334b5ea4322 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
import assert from "assert" | |
import http2 from "http2" | |
//using mocha | |
describe("Http2", ()=>{ | |
it("Should make a get request to google with http2", done => { | |
const uri = "https://www.google.com" | |
const client = http2.connect(uri); | |
const req = client.request({ | |
[http2.constants.HTTP2_HEADER_SCHEME]: "https", | |
[http2.constants.HTTP2_HEADER_METHOD]: http2.constants.HTTP2_METHOD_GET, | |
[http2.constants.HTTP2_HEADER_PATH]: `/` | |
}) | |
req.on("response", (headers, flags) => { | |
assert.equal(headers[":status"], 200) | |
}) | |
req.setEncoding("utf8") | |
const data = [] | |
req.on("data", chunk => data.push(chunk)) | |
req.end() | |
req.on("end", ()=>{ | |
//console.log(data) | |
done() | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment