-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http2: add has method to proxySocketHandler
PR-URL: #35197 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
- Loading branch information
1 parent
a3d5a69
commit 4acb84a
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
if (!common.hasCrypto) { | ||
common.skip('missing crypto'); | ||
} | ||
|
||
const fixtures = require('../common/fixtures'); | ||
const assert = require('assert'); | ||
const http2 = require('http2'); | ||
|
||
const serverOptions = { | ||
key: fixtures.readKey('agent1-key.pem'), | ||
cert: fixtures.readKey('agent1-cert.pem') | ||
}; | ||
const server = http2.createSecureServer(serverOptions, common.mustCall( | ||
(req, res) => { | ||
const request = req; | ||
assert.strictEqual(request.socket.encrypted, true); | ||
assert.ok('encrypted' in request.socket); | ||
res.end(); | ||
} | ||
)); | ||
server.listen(common.mustCall(() => { | ||
const port = server.address().port; | ||
const client = http2.connect('https://localhost:' + port, { | ||
ca: fixtures.readKey('agent1-cert.pem'), | ||
rejectUnauthorized: false | ||
}); | ||
const req = client.request({}); | ||
req.on('response', common.mustCall((headers, flags) => { | ||
console.log(headers); | ||
server.close(common.mustCall(() => { | ||
})); | ||
})); | ||
req.on('end', common.mustCall(() => { | ||
client.close(); | ||
})); | ||
req.end(); | ||
})); |