问题
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