Parts of a URL: host, port, path

孤街浪徒 提交于 2020-01-01 01:25:10

问题


Here is the URL:

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

In my code I have this:

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

From the URL, what is host, what is port and what is path? What are the input values of the method?


回答1:


Host: landfill.bugzilla.org

Port: 443 (default)

Path: bugzilla-tip

http://tools.ietf.org/html/rfc1738




回答2:


  • Host: landfill.bugzilla.org
  • Port: 443 (HTTPS)
  • Path: /bugzilla-tip

for more details please read this




回答3:


Unfortunately the other answers in this question can be slightly misleading. Referring landfill.bugzilla.org to as host is correct in this specific example, but if the port was other than 443 then it would be incorrect.

https:// by default uses port 443, so you may omit it in the URL, otherwise it would of looked like this https://landfill.bugzilla.org:443/bugzilla-tip/:

  • Protocol: https://
  • Hostname: landfill.bugzilla.org
  • Port: 443
  • Host: landfill.bugzilla.org:443
  • Path: bugzilla-tip/

host and hostname are not the same! It's only the "same" when the default ports on the protocol are being used!



来源:https://stackoverflow.com/questions/9260218/parts-of-a-url-host-port-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!