Menu

What is HTTP?

“The language browsers and servers use to talk to each other.”

View .md

HTTP (HyperText Transfer Protocol)Tim Berners-Lee designed the first version at CERN around 1990, together with HTML and the very first web browser. is a set of rules for how a client asks for something and how a server answers.

  • The client is usually your browser, but it can be curl, a mobile app or another server.
  • The server is a program waiting for requests, for example the one behind example.com.

It’s just text#

An HTTP/1.1 message is plain text. This is a real request a browser could send:

http
1GET /index.html HTTP/1.1
2Host: example.com
3Accept: text/html

And a possible answer:

http
1HTTP/1.1 200 OK
2Content-Type: text/html; charset=utf-8
3Content-Length: 41
4
5<html><body><h1>Hello!</h1></body></html>

That’s the whole idea: the client sends a request, the server sends one response back.

Note

Newer versions (HTTP/2 and HTTP/3) send the same information in a compact binary form for speed. The meaning is identical, so everything you learn here still applies.

See it yourself#

curl -v prints the request it sends (lines starting with >) and the response it receives (lines starting with <):

bash
curl -v https://example.com
text
> GET / HTTP/2
> Host: example.com
> User-Agent: curl/8.7.1
> Accept: */*
>
< HTTP/2 200
< content-type: text/html
< content-length: 1256
...

Stateless#

HTTP is stateless: each request stands on its own, and the server doesn’t remember the previous one. Logins and shopping carts work because the client sends something with every request (like a cookie) that lets the server recognize it. We’ll see how in Request headers.

Byte check

0/3

Answer these 3 questions to commit this byte to your learning path.

  1. What does it mean that HTTP is stateless?
  2. In curl -v output, what do the lines starting with < show?
  3. HTTP/2 and HTTP/3 send messages in binary. What changes about their meaning?
Search posts and bytes

Optional account

Keep your progress everywhere

Everything on AminBytes is free to read, with or without an account. Sign in only if you want your commits, streak and merged topics saved, on every device.

or

We keep only your name, avatar and which bytes you finished, and you can delete it all anytime. Privacy