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

http-Server missing hostname in request in UPGRADE event #51516

Closed
weingaunity opened this issue Jan 18, 2024 · 2 comments
Closed

http-Server missing hostname in request in UPGRADE event #51516

weingaunity opened this issue Jan 18, 2024 · 2 comments

Comments

@weingaunity
Copy link

weingaunity commented Jan 18, 2024

Version

10.16.0

Platform

4.13.0-46-generic #51-Ubuntu SMP Tue Jun 12 12:36:29 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

Set up an http Server, when a websocket upgrade would be performed, the request does not contain a hostname property. But other normal http requests will contain in.

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior? Why is that the expected behavior?

The req object in httpserver.on("upgrade",function(req,socket,head){....}) should contain a hostname property

What do you see instead?

req.hostname is missing

Additional information

In req.header and req.rawheader the host property is available including the port-number.

I need this feature to implement a http proxy with websocket support.

@duncanchiu409
Copy link
Contributor

duncanchiu409 commented Jan 19, 2024

Hello, I am not sure if they would put this feature support as priority on their list due to the rather old version. However, there is a similar discussion before which I think might help you. #16712

@weingaunity
Copy link
Author

weingaunity commented Jan 19, 2024

Thx. Though about a similar approach. Now i used following dirty but worky solution:

// req.hostname does not work at "upgrade", so use instead
var url=new URL("http://"+req.headers.host);
console.log(url.hostname)

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

No branches or pull requests

2 participants