HTTP

HTTP is the plain-text conversation behind every web page and API call: a request line and headers from the browser, a status code, headers and a body back from the server.

Load a page

Browser
Server

Message

Press Play to send the first request.

Start line · headers · blank line · body

HTTP is plain text: a request line, headers, a blank line, then an optional body. The response starts with a status code.

Step 1 / 4
Requests
0
Body bytes received
0 B

Step by step

The example above, written out — the same steps the animation plays.

  1. 1Load the same page twice. HTTP is plain text: a request line, headers, a blank line, then an optional body. The response starts with a status code.
  2. 2GET /courses. GET asks for a resource. Host says which site — one server can host many.
  3. 3200 OK. 200 OK with the HTML. ETag is a fingerprint of this version of the page.
  4. 4GET /courses again. The browser still has version "v7", so it asks "send it only if it changed" with If-None-Match.
  5. 5304 Not Modified. 304: nothing changed — use your copy. Just a few hundred bytes instead of 5 KB.
  6. 6Done. Every web page and API call is a conversation like this. HTTPS sends exactly the same text — inside an encrypted TLS connection.

What's happening?

  1. A request names a method (GET, POST…), a path and headers such as Host and Authorization; POST also sends a body.
  2. The response starts with a status code: 2xx success, 3xx go elsewhere or use your copy, 4xx your request has a problem, 5xx the server does.
  3. Headers like ETag and If-None-Match let a browser skip downloading something it already has (304 Not Modified).

Where you'll meet it

Every API you build or call. Reading status codes and headers is the first step in debugging any web or mobile bug.

Common mistake

Returning 200 with an error message in the body. Clients, caches and monitoring rely on the status code — use 4xx and 5xx properly.

FAQ

What is the difference between 401 and 403?

401: we don't know who you are — sign in. 403: we know who you are, and you are not allowed.

301 or 302?

301 is permanent — browsers and search engines remember the new address. 302 is temporary.

What does 304 save?

The whole body. The browser already has that version, so the server only confirms it is still current.