This article is a translation of the first article in a series of articles on the HTTP protocol from
opera.com .
I recreated it so that the article type becomes a translation.
Introduction
In Bhutan, when people meet, they usually greet each other with the words “Does your body feel good?”. In Japan, they can bow, depending on the situation. In Oman, men usually kiss each other on the nose after a handshake. In Cambodia and Thailand, they usually join the palms, as in prayer. These are all communication protocols, a simple sequence of codes that has meaning and prepares both parties to exchange information.
There is a very efficient application layer protocol on the Internet that prepares computers for information exchange:
Hypertext Transfer Protocol , or HTTP. HTTP is an application layer protocol over
TCP / IP communication protocol. HTTP is often overlooked when studying web design and web development, which is a mistake: understanding it helps to determine the best way to interact with users, achieve better website performance and creates an effective tool for managing information on the Internet.
')
This is the first article in a series of articles whose purpose is to teach the basics of HTTP and its effective use. In this article we will see at what stage HTTP works in the Internet mechanism.
What is a communication protocol?
Before delving into the specifics, let's consider the basic communication scenario. To exchange information, both parties (which may be software, devices, people, etc.) must have:
- syntax (data and program code format)
- semantics (information management and error handling)
- timing (timing and sequencing)

When two people meet, they use a communication protocol: for example, in Japan, when meeting someone, a person performs a specific action with the body. One such action is a bow, which is the
syntax used for interaction. In the Japanese tradition, the “bow” gesture (and many others) is associated with the
semantics of greeting someone. As a result, when one person bows to another, a chain of events between these two people is established in a certain
timing .
The online communication protocol consists of the same elements. The syntax is a sequence of characters, like keywords that we use to write a protocol. Semantics is a meaning associated with each of these words and, finally, timing is a sequence in which two or more entities exchange these words.
Where is HTTP wedged into mechanism?
HTTP itself runs on top of other protocols. When connecting to a website, such as
www.example.org , the user agent uses the TCP / IP protocol family.
The TCP / IP model , designed in 1970, consists of
4 levels :
- A network access level describing access to a physical device (i.e. using a network card)
- The internetwork layer describing data locations in a datagram and data routing — how they are packed (IP)
- A transport layer describing the way in which data is delivered from the source to the final receiver (TCP, UDP)
- Application layer that describes the meaning or format of the transmitted messages (HTTP)
HTTP is the
application layer protocol that is above the communication protocol. This is important to keep in mind. Dividing the model into independent levels helps to develop parts of the platform, without having to rewrite everything. For example, TCP, a transport layer protocol, can be developed, without the need to modify HTTP, an application layer protocol. In the first HTTP articles we will focus on level separation, as is done in the TCP / IP model. HTTP is designed to exchange information in two pieces of software using HTTP messages. How we form and design these messages is important both for the client (browser, for example), and for the server (website) and intermediaries (proxy server).
Let's get to the server
Port 80 is the default port for connecting to web servers. We can try to connect to the web server ourselves using the command line. Open a command prompt and try to open a connection to
www.opera.com on port 80 using the following command:
telnet www.opera.com 80
You should get a conclusion like:
Trying 195.189.143.147...
Connected to front.opera.com.
Escape character is '^]'.
Connection closed by foreign host.
We see that the terminal is trying to connect to the server located at 195.189.143.147. If we do nothing more, the server will close the connection itself. Other ports and even another communication protocol can be used, but these are the most common.
Let's talk a little about HTTP
Let's try to connect to the server again. Enter the following message on your command line:
telnet www.opera.com 80
Once the connection is established, enter the following HTTP message quickly (before the connection is automatically closed), then press Enter twice:
GET / HTTP/1.1
Host: www.opera.com
This message means:
- GET: That we want information.
- /: What information we want to get is in the root of the site.
- HTTP / 1.1: That we use HTTP version 1.1.
- Host: We are trying to access a specific site.
- www.opera.com : site name - www.opera.com .
Now it is the turn of the server to respond. You should see in the terminal window the contents of the site, starting with these lines:
HTTP/1.1 200 OK
Date: Wed, 23 Nov 2011 19:41:37 GMT
Server: Apache
Content-Type: text/html; charset=utf-8
Set-Cookie: language=none; path=/; domain=www.opera.com; expires=Thu, 25-Aug-2011 19:41:38 GMT
Set-Cookie: language=en; path=/; domain=.opera.com; expires=Sat, 20-Nov-2021 19:41:38 GMT
Vary: Accept-Encoding
Transfer-Encoding: chunked
<!DOCTYPE html>
<html lang="en">
…
HTTP/1.1 200 OK
Date: Wed, 23 Nov 2011 19:41:37 GMT
Server: Apache
Content-Type: text/html; charset=utf-8
Set-Cookie: language=none; path=/; domain=www.opera.com; expires=Thu, 25-Aug-2011 19:41:38 GMT
Set-Cookie: language=en; path=/; domain=.opera.com; expires=Sat, 20-Nov-2021 19:41:38 GMT
Vary: Accept-Encoding
Transfer-Encoding: chunked
<!DOCTYPE html>
<html lang="en">
…
Here the server responds: “I use HTTP version 1.1. Your request was successful, so I answer with the code 200 ". The Ok line is optional and is present to explain to people what this code means to people - in this case, everything is good and our request has been successfully processed. Further, a series of HTTP headers is sent to explain what this message is and how it should be understood. As a result, the content of the page located in the root of the site is added to the answer starting with the line <! DOCTYPE html>. The list of HTTP keywords and response codes will be described in the following articles.

Summary
We communicated with the web server using the HTTP protocol - it's as simple as possible! We sent a message (exactly as if we had written a letter) and received an answer that our message was understood. Next time we take a closer look at what some of these headers mean and how they can be used.