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

http2.connect with url starting with "http://" does not pass options to net.connect #29811

Closed
sogaani opened this issue Oct 2, 2019 · 0 comments
Labels
http2 Issues or PRs related to the http2 subsystem.

Comments

@sogaani
Copy link

sogaani commented Oct 2, 2019

  • Version:
    v12.11.1

  • Platform:
    Windows Subsystem Linux
    Linux A062787428 4.4.0-17134-Microsoft Fix/postmortem #706-Microsoft Mon Apr 01 18:13:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux

net.connect() options has no effect when I execute http2.connect, thought The document says "Any net.connect() or tls.connect() options can be provided."

Related codes is here which does not pass options of http2.connect to net.connect().

Code to reproduce.

'use strict';
const common = require('../common');
if (!common.hasMultiLocalhost())
  common.skip('platform-specific test.');

const http2 = require('http2');
const assert = require('assert');

const server = http2.createServer((req, res) => {
  console.log(`Connect from: ${req.connection.remoteAddress}`);
  assert.strictEqual(req.connection.remoteAddress, '127.0.0.2');

  req.on('end', () => {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end(`You are from: ${req.connection.remoteAddress}`);
  });
  req.resume();
});

server.listen(0, '127.0.0.1', () => {
  const options = { localAddress: '127.0.0.2' };

  const client = http2.connect('http://localhost:' + server.address().port, options);
  const req = client.request({
    ':path': '/'
  });
  req.on('data', () => req.resume())
  req.on('end', function() {
    client.close();
    req.close();
    server.close();
    process.exit();
  });
  req.end();
});
@ZYSzys ZYSzys added the http2 Issues or PRs related to the http2 subsystem. label Oct 2, 2019
@ZYSzys ZYSzys closed this as completed in 95266db Oct 7, 2019
BridgeAR pushed a commit that referenced this issue Oct 9, 2019
PR-URL: #29816
Fixes: #29811
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http2 Issues or PRs related to the http2 subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants