简体   繁体   English

NodeJS Net获取请求域名

[英]NodeJS Net get domain name for request

Is it possible to determine the domain name for an incoming request using the NodeJS net API? 是否可以使用NodeJS net API确定传入请求的域名?

For example, could the following code be modified to allow me to access the domain name? 例如,是否可以修改以下代码以允许我访问域名?

net.createServer(function (socket) {

  socket.on('data', function (data) {
    // Possible to get incoming domain name?
  });

  socket.on('end', function () {
    // Possible to get incoming domain name?
  });

}).listen(6000);

TCP requests have nothing to do with domain names. TCP请求与域名无关。
The information you're looking for does not exist anywhere. 您要查找的信息不存在任何地方。

The only reason this is possible in HTTP is that the client explicitly sends the domain name in the Host: header. 在HTTP中可能的唯一原因是客户端在Host:标头中显式发送域名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM