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 worldwide web. Information on the worldwide web is presented in documents, called web pages, that contain hypertext, called links. When you click on links, you can open another document on the worldwide web, hence the name.

When your browser resolves a domain name's IP address through the Domain Name System (DNS), your browser needs to communicate with the web server at that IP address to load the web page. In order to load the web page, your browser makes a series of HTTP requests to the web server.

What is the Hypertext Transfer Protocol HTTP

HTTP is an asymmetric request-response protocol. This means that the client, usually your web browser, requests information from the web server and the web server responds with requested information. HTTP is a pull protocol, because information can only be pulled from a web server after a client's request. The web server never pushes 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, when you load a web page.

For POST requests, the browser asks to send some data to the web server. For example, when you enter your username and password into a form in your browser window. HTTP POST requests are sent inside the HTTP request body.

HTTP Responses

When a web server responds to a browser's HTTP request, it returns a status code to the browser. An HTTP status code is a three-digit code that indicates the results of the HTTP request. One of the most famous HTTP status codes that you've probably come across is the 404 Not Found error, which usually results from web pages being moved or deleted from 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) the information returned in the HTTP response body will contain HTML instructions to format the web page (text, images, colors, and so on).

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 one has been terminated, the web server forgets everything about the previous connection. In order to preserve the information from previous connections, cookies can be used to store session information.

Glossary

DNS

Domain Name System. A protocol that resolves names to IP addresses that devices can use to contact other servers.

HTTP

Hypertext Transfer Protocol. A protocol that connects web browsers to web servers when they request content.

DNS Resolver

A service that resolves domain names into network addresses.