【发布时间】:2012-02-13 12:05:18
【问题描述】:
这是网址:
https://landfill.bugzilla.org/bugzilla-tip/
在我的代码中我有这个:
Server server = new Server(host, port, path);
从 URL 看,什么是主机,什么是端口,什么是路径?方法的输入值是多少?
【问题讨论】:
标签: web-services path host
这是网址:
https://landfill.bugzilla.org/bugzilla-tip/
在我的代码中我有这个:
Server server = new Server(host, port, path);
从 URL 看,什么是主机,什么是端口,什么是路径?方法的输入值是多少?
【问题讨论】:
标签: web-services path host
【讨论】:
不幸的是,这个问题的其他答案可能会有点误导。在此特定示例中,将landfill.bugzilla.org 称为host 是正确的,但如果端口不是443,则将不正确。
https:// 默认使用端口443,所以你可以在URL 中省略它,否则它看起来像https://landfill.bugzilla.org:443/bugzilla-tip:
https://
landfill.bugzilla.org
443
landfill.bugzilla.org 或 landfill.bugzilla.org:443(视情况而定,请阅读下文)landfill.bugzilla.org:443
bugzilla-tip
host 和 hostname 在所有情况下都不相同。例如在 JavaScript 中 location.host 将返回 www.geeksforgeeks.org:8080 而 location.hostname 返回 www.geeksforgeeks.org。因此,有时仅在使用协议上的默认端口时“相同”。
【讨论】:
landfill.bugzilla.org
443 (HTTPS)/bugzilla-tip
更多详情请阅读this
【讨论】:
host(或port)和url-path之间的“/”不是url-path的一部分。我>