-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
info.origin and info.req.headers.host issue in verifyClient after upgrade ws from 1.1.4 to 3.3.3 #1271
Comments
I'm not sure, Is the client a browser? |
req.headers['sec-websocket-version'] is 13, therefor origin is req.headers['origin'] |
yes that's correct. |
right, but I still don't understand why req.headers['origin'] comes without port and info.req.headers.host comes with port 443 :) |
They are set by the client, are |
Yes, on 1.1.4 origin and host are the same. |
I already printed it and saw that the host has port 443 in 3.3.3 and does not has port at all in 1.1.4. I open this github issue only after I printed it and saw the difference. |
I cannot reproduce, here is my code. const https = require('https');
const fs = require('fs');
const WebSocket = require('.');
const data = `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script>
(function () {
var ws = new WebSocket('wss://localhost');
})();
</script>
</body>
</html>`;
const server = https.createServer({
cert: fs.readFileSync('test/fixtures/certificate.pem'),
key: fs.readFileSync('test/fixtures/key.pem')
});
server.on('request', (req, res) => {
res.setHeader('Content-Type', 'text/html');
res.end(data);
});
const wss = new WebSocket.Server({
verifyClient (info) {
console.log(info.origin);
console.log(info.req.headers.host);
return true;
},
server
});
wss.on('connection', (ws) => ws.close());
server.listen(443); This prints the same stuff on both 1.1.4 and 3.3.3 using Chrome as client. |
@rutanika I've also tested it on Firefox and it works the same on both 1.1.4 and 3.3.3. |
Closing as I can't reproduce this, discussion can continue on the closed thread. |
Hi, |
Hello,
After we upgraded ws from 1.1.4 to 3.3.3 and did the adjustment as suggested in #1099, we get different behaviour in verifyClient.
We recognized that in verifyClient info.origin comes without port and info.req.headers.host comes with port 443.
Without the change both of them comes without the port.
Do you know what can be the reason for that?
Thanks,
Tali
node version: 6.0.0
platform: cf
The text was updated successfully, but these errors were encountered: