Menu
What is HTTP?
“The language browsers and servers use to talk to each other.”
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:
1GET /index.html HTTP/1.1
2Host: example.com
3Accept: text/htmlAnd a possible answer:
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 <):
curl -v https://example.com> 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.
Answer these 3 questions to commit this byte to your learning path.
Reset. This byte isn't committed any more. Answer the questions again to commit it.
$ git commit -m "learn(http): What is HTTP?"
[main 1ddae34] learn(http): What is HTTP?
1 byte changed, 3 insertions(+)
See it on your path Already committed . Try the questions again any time, it won't undo anything. To uncommit it and start over: