Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add proxy handler "has" for "http2.Http2ServerResponse.socket" and "http2.Http2ServerRequest.socket" #35197

Closed
wants to merge 17 commits into from
Closed
7 changes: 7 additions & 0 deletions lib/internal/http2/compat.js
Expand Up @@ -188,6 +188,13 @@ function resumeStream(stream) {
}

const proxySocketHandler = {


has(stream, prop) {
const ref = stream.session !== undefined ? stream.session[kSocket] : stream;
return (prop in stream ) || (prop in ref);
},

get(stream, prop) {
switch (prop) {
case 'on':
Expand Down
36 changes: 36 additions & 0 deletions test/parallel/test-for-pull-35197.js
@@ -0,0 +1,36 @@
'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
const assert = require('assert');
const http2 = require('http2');
if (!common.hasCrypto){
common.skip('missing crypto');

}
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(true === request.socket.encrypted);
assert('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();
}));