HTTP requests and responses
Every web page starts with a short text conversation. Your browser asks, the server answers. Follow one visit to www.example.com: the request line and its headers, the status line and the body that come back, a redirect, why HTTP forgets you and how cookies fix that, and how HTTP/1.1, HTTP/2 and HTTP/3 carry the same messages faster.
5 quick questions
Pick an answer to see why. Your score saves with your progress.
01In the request line GET /index.html HTTP/1.1, what is /index.html?
A request line has three parts: the method (GET), the target path (/index.html) and the version (HTTP/1.1). The server's name goes in the Host header.
02Why must every HTTP/1.1 request carry a Host header?
Many sites can share one IP address. The Host header names the site, and an HTTP/1.1 server answers 400 Bad Request if it is missing (RFC 9112 §3.2).
03A server answers 404 Not Found. Which family is that, and what does it mean?
The first digit gives the family. 4xx codes say the request could not be served as asked; 404 means there is nothing at that path. A server failure would be 5xx, such as 500.
04HTTP is stateless. How does a site remember that you logged in?
Each request stands alone, so the server hands the browser a cookie (here SID=31d4d96e407aad42). The browser stores it for that site and returns it with every later request, which lets the server recognise you (RFC 6265).
05What does HTTP/3 change compared with HTTP/2?
HTTP/2 and HTTP/3 keep the same methods, codes and headers. HTTP/2 multiplexes streams over one TCP connection, where one loss stalls them all; HTTP/3 uses QUIC, whose streams recover from loss independently.
Glossary
- HTTP
- Hypertext Transfer Protocol: the request-and-response language browsers and web servers speak.
- Request line
- The first line of a request: a method, a path and a version, such as GET /index.html HTTP/1.1.
- Method
- The verb of a request. GET asks for something; POST sends data, such as a form.
- Header
- A Name: value line after the first line, such as Host or Content-Type. An empty line ends the headers.
- Status code
- The three-digit result in a response. The first digit is the family: 2xx success, 3xx redirect, 4xx request problem, 5xx server problem.
- Stateless
- Each request stands on its own; the server keeps no memory of earlier ones by itself.
- Cookie
- A small piece of text a server sets with Set-Cookie and the browser sends back with Cookie, so the site can recognise you.
- Multiplexing
- Sending many requests and responses at once on one connection as separate streams (HTTP/2 and HTTP/3).
Notes and sources
- 192.0.2.7 and 203.0.113.10 are RFC 5737 documentation addresses and www.example.com is reserved for examples (RFC 2606), the same ones the TCP and HTTPS lessons use.
- Illustrative values: the page size (1256 bytes), the paths, the login form and the port 51514. The cookie value SID=31d4d96e407aad42 is the example from RFC 6265.
- Plain http:// sends everything, passwords and cookies included, as readable text. Real sites use https://, which wraps the same HTTP messages in TLS (see the HTTPS lesson).
- HTTP/2 (RFC 9113) and HTTP/3 (RFC 9114) keep the same methods, status codes and headers (RFC 9110); they only change how messages are carried. They drop the reason phrase, so a status line is just the code.
- The cards show a shortened message: a real browser sends more headers (User-Agent, Accept-Language, Accept-Encoding …) and the server adds Date, Server and others.
Quiz Unlocks after the last step.