NewThe ManyPI MCP Server is now live

How HTTP works, from request to status code

What happens between typing an address and seeing a page, shown with a real request and response. Status codes, the headers that matter and an exercise with a live tool.

Guide45 minBachelor +2CC BY 4.0

What you will learn

  • Describe a request and a response and what each contains
  • Sort status codes into their five classes
  • Explain what common headers such as content-type, location and cache-control do
  • Read a live response with a tool

Request and response

A browser asks, a server answers. Both messages are plain text with the same shape: a first line, headers, a blank line and an optional body.

A request
GET /index.html HTTP/1.1
Host: example.com
Accept: text/html
User-Agent: Mozilla/5.0
The response
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Cache-Control: max-age=3600
Content-Length: 1256

<!doctype html>
...

The method (GET) says what the browser wants to do: GET reads, POST sends data, for example a form.

Status codes

The three digits sort every response into one of five classes.

Class

Meaning

Examples

1xx

Information, keep going

100 Continue

2xx

Success

200 OK, 201 Created, 204 No Content

3xx

Look elsewhere

301 Moved Permanently, 302 Found, 304 Not Modified

4xx

The request has a problem

400 Bad Request, 403 Forbidden, 404 Not Found, 429 Too Many Requests

5xx

The server has a problem

500 Internal Server Error, 503 Service Unavailable

A 3xx answer carries a Location header with the new address, and the browser follows it on its own.

Headers worth knowing

  • content-type: what the body is, such as text/html or application/json.

  • cache-control: how long the browser may reuse the response without asking again.

  • location: where a redirect points.

  • set-cookie: a small value the browser stores and sends back with later requests.

  • strict-transport-security: tells the browser to use HTTPS for this site from now on.

Exercise

  1. Open the HTTP Header Analyzer and request https://example.com. Which status code comes back, and what is the content-type?

  2. Request the same address with http:// instead. Is there a redirect? Which header gives it away?

  3. Request an address that does not exist on a site you know, such as /does-not-exist. Which class does the status code belong to?

  4. Find one header in a response that is not on the list above and look up what it does.

Reuse this material

CC BY 4.0

You may copy, adapt and share it, also commercially, as long as you credit ManyPI and link back.

"How HTTP works, from request to status code" by ManyPI (https://manypi.com/edu/how-http-works), licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)