HTTP and web clients

The first thing to understand is that when people say client or server they just mean a computer program that is capable of using the magical portal of the Internet. The most common example of a web client is a web browser: Google Chrome, Firefox, Safari etc. Nowadays quite often a web client is built into other appreciations. For example, a game you play on your phone can show you the global leader board by connecting to some server via the Internet.

You can think of a web client as a human client in a restaurant. The waiters in this restaurant are a bit shy, and they never talk to you first, but diligently wait for your requests. So, on the web everything starts with the client.

Tom's Restaurant in New York City

While in a restaurant, you obey multiple rules of communication and interaction. Both you and the waiter speak the same language and know these rules. If you say something that doesn't make sense in the context of a restaurant, like "let me dance with the cats while you watch", the waiter will probably tell you that they don't understand you. But if you follow the rules and pick something from the menu, the waiter will bring it to you.

The situation is similar when a web client is interacting with the web server. There is a set of rules, a language of sorts that both client and the server speak. Don't confuse this language with a programming language. Programming languages are the languages in which the programs are written. But this web language is the language that programs speak. Similar to programming languages, the web language must be strict and simple, so that it's equally effective for programs to interpret and humans to read or write.

Languages like that are called protocols. To avoid further confusion with programming languages, we shall only call them protocols from now on.

The protocol which the web browser uses to communicate with the server is called HTTP: Hypertext Transfer Protocol. Hypertext is a fancy word for "interactive, rich text and multimedia", in other words, all that cool stuff we see in the browser: pages, images, videos, animations.

HTTP consists of methods (also called 'verbs' sometimes) and some additional information. There are just a few of possible methods. The one we are interested in right now is called GET. It makes sense, since we want to get a web page.

So, assuming the client knows how to address the server, all it needs to do is to write down its request following the rules of HTTP. It is literally some text written down and sent via that magical portal. This is how it looks like for the simplest kind of request — a GET request that, as the name suggests, asks the server to get some information.

GET /article.html HTTP/1.1
Host: coolsite.com

The first thing after the GET verb is the name of the thing that we are interested in. In this case, it's a file called article.html. Then the rules require us to specify the version of the protocol. The client and the server need to make sure that they speak the same language, and just like human languages, the HTTP protocol changes over time. When a change occurs, it is marked as a new version. So, here, by saying HTTP 1.1 the client signals to the server that its request follows the rules of a HTTP version 1.1.

It would be interesting if we did the same in our everyday lives. Imagine someone approaching you on the street and asking for directions by first declaring the version of the language they speak:

— Hello, I'm speaking NYC slang. Yo, I'm mad lost, which way to Daly avenue?

The second line of the request must specify the host or in other words a website. This is needed because on the other side of the portal is a computer, and the Web server on that computer might be running multiple websites at the same time. By specifying the host the client makes sure that its request is delivered to the particular website. And that's it. A small computer program capable of sending this text into the portal is considered to be a web client. Of course, useful with client will also be capable of processing whatever response the server sends back. Which brings us to the second piece of the puzzle.