Skip to the workspace
Pebellslearn by building
How the Internet Works  ›  Lesson

HTTP — Asking and Answering

What is HTTP? 14 minHTTP is the request and response conversation of the web: the browser sends a method and a path, and the server replies with a status code, headers and a body.

frontend / HTTP — Asking and Answering

Explore each scene at your own pace.

01 · The rule

The rule

HTTP — Asking and Answering

Packets can carry anything, so the browser and the server need an agreed way to say "please send me the menu page" and "here it is". That agreement is HTTP, the HyperText Transfer Protocol. Every page, image, stylesheet and script on the bakery site arrives through an HTTP conversation.

The rule

The browser asks with a method and a path; the server answers with a status.

An HTTP request is plain, readable text. Opening the bakery's menu sends something like this:

GET /menu HTTP/1.1
Host: crumbbakery.com
Accept: text/html
  • Method (GET): what you want done. GET fetches, POST sends new data such as an order form, PUT and PATCH update, DELETE removes.
  • Path (/menu): which thing on the server.
  • Headers (Host, Accept): extra details, one per line, as Name: value.

The response comes back in the same shape:

HTTP/1.1 200 OK
Content-Type: text/html

<!DOCTYPE html>
<html>...the menu page...</html>

The number is the status code, and its first digit tells you the story:

Class Meaning Examples
2xx It worked 200 OK, 201 Created
3xx Look somewhere else 301 Moved Permanently, 304 Not Modified
4xx The request was wrong 404 Not Found, 401 Unauthorized, 403 Forbidden
5xx The server failed 500 Internal Server Error, 503 Service Unavailable

HTTP is stateless: each request stands alone, and the server does not automatically remember the previous one. Sites remember who you are by sending something with every request, most often a cookie.

HTTPS is the same conversation wrapped in encryption (TLS), so nobody on the path can read or quietly change it. Today every public site should use it.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.