Lesson 3 of 18
3. Client and Server

3.2 What's a request and a response?

3 min read+10 XP

In the restaurant: One slip, one plate. You write exactly what you want ("table 4, one masala dosa, no onion"), and you get back exactly that, or the waiter comes back and says "sorry, we're out".

In the system: HTTP works as request and response. The client sends one request; the server sends back one response.

REQUEST RESPONSE GET /books/42 HTTP/1.1 HTTP/1.1 200 OK Host: shop.example.com Content-Type: application/json Accept: application/json Content-Length: 61 {"id": "42", "title": "Designing Systems", "price": 499}
  • The request says what you want: a method (GET), a path (/books/42), headers and sometimes a body.
  • The response says what happened: a status code (200), headers, and usually a body.

The key rule: the client always starts. In plain HTTP, a server can't send you anything you didn't ask for. If the server has news (a new chat message, a price change), you need extra techniques like polling, WebSockets or push notifications (Chapter 21).

Memory code: "One slip, one plate. Nothing is served that wasn't ordered."