The Hypertext Transfer Protocol (HTTP)

What is HTTP?

The Hypertext Transfer Protocol (HTTP) is the set of instructions that govern how applications transfer information on the World Wide Web. Information on the World Wide Web is presented in documents (commonly known as web pages) that contains hypertext (commonly known as links) that you click on to get information from another document on the World Wide Web, hence the name.

After your browser resolves a domain name’s IP address through the Domain Name System (DNS), your browser will need to communicate with the web server at that IP address to transfer information necessary to load the web page in your browser window. In order to load the web page, your browser will make a series of HTTP requests to the web server.

What is the Hypertext Transfer Protocal HTTP

HTTP is an asymmetric request-response protocol. This means that the client (which usually refers to your web browser) requests information from the web server, and the web server will respond with the requested information. Therefore, HTTP is a pull protocol because information can only be pulled from the web server following a client’s request. The web server does not push information to a client without a request.

HTTP Requests

There are different HTTP request methods, but two of them are the most common: “GET” and “POST”. For “GET” requests, the browser asks the web server to send information over (for example, to load a web page), while for “POST” requests, the browser says it wishes to some data over to the web server (for example, the username and password that has been entered in a form inside a browser window).

In a HTTP “POST” request, the information that the web browser passes to the web server, such as the values of the username and password entered into a form (or any other information entered into other fields in the form), is sent inside the HTTP request body.

HTTP Responses

When a web server responds to a browser’ HTTP request, it first returns a status code to the browser. What the HTTP status code is is a three-digit code that indicates the results of the HTTP request. One of the most famous HTTP status codes that you may have come across is the “404 Not Found” error, which usually results from the web page being moved or deleted on the server. HTTP status codes are divided into five categories, each beginning with a different digit:

  • Informational codes (begins with 1)
  • Success codes (begins with 2)
  • Redirection codes (begins with 3)
  • Client error codes (begins with 4)
  • Server error codes (begins with 5)

Finally, in the HTTP response body, if the HTTP response status code indicates success (e.g. code 200 as shown in the above header) the information returned in the HTTP response body will contain the HTML instructions for the browser to format the information on the page (text, images, colors, positions etc) for display in the browser window.

HTTP as a stateless protocol

HTTP is also known as a stateless protocol because each connection between the client and web server is terminated after transacting. When the same client opens a new connection to the server right after the previous has been terminated, the web server does not remember anything about the previous connection. In order to preserve the information from previous connections, cookies can be used to temporarily store session information.

Glossary

DNS

DNS is a protocol that resolves names (such as bunny.net) to computer IP addresses (like 1.1.1.1) that your computer can use to contact other servers to obtain information or data

HTTP

HTTP is a protocol used to connect to web servers by web browsers to request content to view. This is also used to transfer larger files, and is often used for software updates.

DNS Resolver

DNS resolver is a service used by a client or computer to resolve domain names into network addresses.