URLs, man
This afternoon, I read about URLs in Introduction to HTTP. Again, many thanks to Launch School for making this book available via their Open Book Shelf. My notes are directly attributable to the content from their book.
A URL comprises 3 main components:
- http: this is the URL scheme; it tells the web client how to access the resource. “http” tells the web client to use HTTP to make a request; other common URL schemes are ftp, mailto or git.
- cherimoya.com: this is the resource path or host; it tells the client where the resource is hosted or located.
- /home/: this is the URL path; it shows what local resource is being requested.
URLs can also include a port number which the host uses to listen to HTTP requests. The default port number for HTTP is port 80. Even though this port number isn’t always specified, it’s assumed to be part of every URL. Unless a different port number is specified, port 80 is used by default in normal HTTP requests.
A URL might also include a query string or parameter, which usually contains some form of data to be sent to the server. In the following URL…
http://avocadoshop.com?variety=hass&size=tiny&status=ripe
… name/value pairs in the form of variety=hass, size=tiny, and status=ripe are passed to the server from the URL. This request asks the avocadoshop.com server to locate a record with the given parameter values.
By default, URLs accept only certain characters in the ASCII character set. URL encoding replaces non-conforming characters with a % symbol followed by two hexadecimal digits that represent the ASCII code of the character, e.g.:
http://pomegranate-world.org/pomegranate%20trees.html
N.B. & (ampersand) is reserved for use as a query string delimiter. : (colon) is also reserved to delimit host/port components and user/password.