Skip to content

Instantly share code, notes, and snippets.

@joeyguerra
Last active September 7, 2020 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeyguerra/e55102c543cf30a13e14c334b5ea4322 to your computer and use it in GitHub Desktop.
Save joeyguerra/e55102c543cf30a13e14c334b5ea4322 to your computer and use it in GitHub Desktop.
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