-
Notifications
You must be signed in to change notification settings - Fork 30k
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: code examples does not work on Windows with port 80 #14304
Comments
Will look into it! Thank you! :-) |
ping @vsemozhetbyt — is this still the case for you? |
@apapirovski Yes, the behavior from the first post remains with Node.js 8.7.0 or the last nightly build. |
@vsemozhetbyt Could you try the same with |
@apapirovski Let me know if I use wrong test examples. 'use strict';
const http = require('http');
const hostname = 'localhost';
const port = 81;
const server = http.createServer((req, res) => {
console.log(req.headers);
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World\n');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
}); Client: 'use strict';
const http = require('http');
http.get({
hostname: 'localhost',
port: 81,
path: '/',
}, (res) => {
console.log(res.headers);
}); Port 81, Server: Server running at http://localhost:81/
{ host: 'localhost:81', connection: 'close' } Port 81, Client: { 'content-type': 'text/plain',
date: 'Thu, 19 Oct 2017 12:30:28 GMT',
connection: 'close',
'content-length': '12' } Port 80, Server: Server running at http://localhost:80/
{ host: 'localhost', connection: 'close' } Port 80, Client: { 'content-type': 'text/plain',
date: 'Thu, 19 Oct 2017 12:31:35 GMT',
connection: 'close',
'content-length': '12' } |
Thanks so much for testing |
Due to how WHATWG-URL parser works, port numbers are omitted if they are the default port for a scheme. This meant that http2.connect could not accept connections on port 80 with http scheme. Fix this bug by detecting http: scheme and setting port to 80. Fixes: nodejs#14304
Due to how WHATWG-URL parser works, port numbers are omitted if they are the default port for a scheme. This meant that http2.connect could not accept connections on port 80 with http scheme. Fix this bug by detecting http: scheme and setting port to 80. PR-URL: #16337 Fixes: #14304 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
Due to how WHATWG-URL parser works, port numbers are omitted if they are the default port for a scheme. This meant that http2.connect could not accept connections on port 80 with http scheme. Fix this bug by detecting http: scheme and setting port to 80. PR-URL: nodejs/node#16337 Fixes: nodejs/node#14304 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
Due to how WHATWG-URL parser works, port numbers are omitted if they are the default port for a scheme. This meant that http2.connect could not accept connections on port 80 with http scheme. Fix this bug by detecting http: scheme and setting port to 80. PR-URL: nodejs/node#16337 Fixes: nodejs/node#14304 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
Refs: #14239 (http2.md)
The first examples from "Core API" chapter do not work properly on Windows with port 80 but work with other ports.
I've added some output and repeated request for easier debugging. Here are the code and output with port 81:
Server:
Client:
Server output:
Client output:
When I change the port in both examples into 80, I get:
Server output:
(node:4792) ExperimentalWarning: The http2 module is an experimental API.
Client output:
FWIW, I've tried to see what was going on with TCPView:
The first two is the Server, the last two are Client requests and they are trying to connect the 443 port.
The text was updated successfully, but these errors were encountered: