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
5 changes: 5 additions & 0 deletions lib/internal/http2/compat.js
Expand Up @@ -188,6 +188,11 @@ function resumeStream(stream) {
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional suggestion: The test file only covers one of these conditions, right? Does it make sense to add a test case so that both are covered?

},

get(stream, prop) {
switch (prop) {
case 'on':
Expand Down
39 changes: 39 additions & 0 deletions test/parallel/test-for-pull-35197.js
@@ -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();
}));