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

Handle :scheme and :path in CONNECT #445

Merged
merged 2 commits into from
Mar 9, 2020
Merged

Conversation

kornelski
Copy link
Contributor

If the :method is CONNECT the :scheme and :path pseudo-header fields MUST be omitted

This is for #234

@kornelski
Copy link
Contributor Author

I've verified that Node.js's HTTP/2 can make a request to an h2 server from examples.

const http2 = require('http2');

const client = http2.connect('http://127.0.0.1:5928');

// Must not specify the ':path' and ':scheme' headers
// for CONNECT requests or an error will be thrown.
const req = client.request({
  ':method': 'CONNECT',
  ':authority': `127.0.0.1:5928`,
});

req.on('response', (headers) => {
  console.log("resp", headers[http2.constants.HTTP2_HEADER_STATUS], headers);
});

req.on('error', (err) => console.error("boo", err));
req.setEncoding('utf8');
let data = '';
req.on('data', (chunk) => data += chunk);
req.on('end', () => {
  console.log(`The server says: ${data}`);
  client.close();
});
req.end('Jane');

Copy link
Member

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

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

Looks right, thanks!

We should probably add a test in h2-tests/tests/server.rs exercising this.

If the :method is CONNECT the :scheme and :path pseudo-header fields MUST be omitted
@kornelski
Copy link
Contributor Author

I've added a test and rebased on master.

@seanmonstar seanmonstar merged commit 5041a4d into hyperium:master Mar 9, 2020
@kornelski kornelski deleted the connect branch March 9, 2020 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants