petko_stankoski
petko_stankoski

Reputation: 10713

Parts of a URL: host, port, path

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?

Upvotes: 33

Views: 71687

Answers (4)

Zeta
Zeta

Reputation: 1

In your case with Host the code is referring to: landfill.bugzilla.org *

Port: By default the https port is 443, but you should check this.

Path: /bugzilla-tip

*Although this is theoretically not quite correct, just put it that way for simplicity.

landfill.bugzilla.org is the URL that indicates to which DNS servers it has to go to resolve the Host name, which is "landfill".

The correct answer at the configuration level is that the host is "landfill" and "landfill.bugzilla.org" is the full URL that tells you what the host is and what server you have to go to in order to find it.

Translated with www.DeepL.com/Translator (free version)

Upvotes: 0

basickarl
basickarl

Reputation: 40464

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 or landfill.bugzilla.org:443 (depending, read below)
  • Hostport: landfill.bugzilla.org:443
  • Path: bugzilla-tip

host and hostname are not the same in all instances. For example in JavaScript location.host will return www.geeksforgeeks.org:8080 while location.hostname returns www.geeksforgeeks.org. So sometimes it's only the "same" when the default ports on the protocol are being used depending.

More info: https://www.rfc-editor.org/rfc/rfc1738

Have a look at this: http://bl.ocks.org/abernier/3070589

Upvotes: 25

Chuck R
Chuck R

Reputation: 741

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

for more details please read this

Upvotes: 12

user996142
user996142

Reputation: 2883

Host: landfill.bugzilla.org

Port: 443 (default)

Path: bugzilla-tip

https://www.rfc-editor.org/rfc/rfc1738

Upvotes: 34

Related Questions