Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 877
petko_stankoski Avatar asked Feb 13 '12 12:02

petko_stankoski


People also ask

What are the parts of a URL path called?

A URL consists of five parts: the scheme, subdomain, top-level domain, second-level domain, and subdirectory.

What is host and port in URL?

The host property of the URL interface is a string containing the host, that is the hostname , and then, if the port of the URL is nonempty, a ':' , followed by the port of the URL. Note: This feature is available in Web Workers.

What are the 3 parts to a URL route?

To recap, these are the three basic elements of a website URL: The protocol – HTTP or HTTPS. The domain name (including the TLD) that identifies a site. The path leading to a specific web page.


2 Answers

Host: landfill.bugzilla.org

Port: 443 (default)

Path: bugzilla-tip

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

like image 174
user996142 Avatar answered Sep 24 '22 20:09

user996142


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

like image 26
basickarl Avatar answered Sep 26 '22 20:09

basickarl