Created
September 15, 2017 10:54
-
-
Save apapirovski/3f9605bec6bb539a0945a964492374e1 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 common = require('./test/common'); | |
const { readFileSync } = require('fs'); | |
const { join } = require('path'); | |
const { createSecureContext } = require('tls'); | |
const h2 = require('http2'); | |
const key = loadKey('agent8-key.pem'); | |
const cert = loadKey('agent8-cert.pem'); | |
const ca = loadKey('fake-startcom-root-cert.pem'); | |
function loadKey(keyname) { | |
return readFileSync(join(common.fixturesDir, 'keys', keyname)); | |
} | |
const server = h2.createSecureServer({ | |
cert, | |
key, | |
}); | |
server.on('request', (req, res) => res.end()); | |
server.on('timeout', () => console.log('timeout')); | |
server.listen(0, () => { | |
const port = server.address().port; | |
const url = `https://localhost:${port}`; | |
const client = h2.connect(url, { | |
secureContext: createSecureContext({ ca }) | |
}); | |
makeReq(); | |
function makeReq() { | |
console.log('heartbeat'); | |
const request = client.request({ | |
':path': '/foobar', | |
':method': 'GET', | |
':scheme': 'http', | |
':authority': `localhost:${port}`, | |
}); | |
request.end(); | |
setTimeout(makeReq, 60000); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment