Web Services URL的组成部分:主机、端口、路径

pxq42qpu  于 2022-11-15  发布在  其他
关注(0)|答案(3)|浏览(165)

以下是URL:

https://landfill.bugzilla.org/bugzilla-tip/

在我的代码中,我有这样的代码:

Server server = new Server(host, port, path);

从URL看,什么是host,什么是port,什么是path?方法的输入值是什么?

ubby3x7f

ubby3x7f1#

主持人landfill.bugzilla.org
端口:443(默认)
路径:bugzilla-提示
https://www.rfc-editor.org/rfc/rfc1738

zour9fqk

zour9fqk2#

不幸的是,此问题中的其他答案可能会有些许误导。在此特定示例中,将landfill.bugzilla.org称为host是正确的,但如果端口不是443,则将是不正确的。
默认情况下,https://使用端口443,因此您可以在URL中省略它,否则它看起来会像https://landfill.bugzilla.org:443/bugzilla-tip

*协议https://
*主机名landfill.bugzilla.org
*连接埠443
*主机landfill.bugzilla.orglandfill.bugzilla.org:443(具体取决于以下内容)
*主机端口landfill.bugzilla.org:443
*路径bugzilla-tip

hosthostname在所有示例中并不相同。例如,在JavaScript中,location.host将返回www.geeksforgeeks.org:8080,而location.hostname将返回www.geeksforgeeks.org。因此,有时只有在使用协议上的默认端口时,才会“相同”。
更多信息:https://www.rfc-editor.org/rfc/rfc1738
看看这个:http://bl.ocks.org/abernier/3070589

8ljdwjyq

8ljdwjyq3#

  • 主机:landfill.bugzilla.org
  • 连接埠:443(HTTPS)
  • 路径:/bugzilla-tip

更多详情请阅读this

相关问题