Sikau

Web essentials · Day 1 · about 25 min

HTTP: requests and responses

What really happens when you open a page.

A conversation between computers

Type an address and press Enter: your browser sends a request, a server sends back a response. Every image, stylesheet and API call is one of these little conversations, spoken in HTTP.

Anatomy of a request and response

GET /menu HTTP/1.1
Host: momohouse.example
Accept: text/html

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Cache-Control: max-age=600

<!doctype html><title>Menu</title>…
  • Methods: GET read, POST create, PUT/PATCH update, DELETE remove.
  • Status codes: 2xx success (200 OK, 201 Created), 3xx redirect (301, 304 Not Modified), 4xx your mistake (400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found), 5xx the server's mistake (500, 503).
  • HTTPS is HTTP encrypted, so nobody in between can read or change it.

The rest of this lesson

  • Headers do a lot of workexplain
  • Choosing the right status codeexplain
  • Whose fault?predict
  • Status code meaningsmatch
  • Your turnwrite code
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 16 lessons of Web essentials