Module 1 · FundamentalsLesson 3 of 886 minBeginner

HTTP and HTTPS

HTTP is the language browsers and servers speak. HTTPS is the same language, sealed in an envelope.

Try it

Step through the tabs. Watch the status code on each answer, then compare what the person on the cafe Wi-Fi sees with plain HTTP and with HTTPS.

Every HTTP request has the same parts:

  • a method: what you want to do,
  • a path: which thing, like /orders/42,
  • headers: extra information, like who you are or what format you accept,
  • sometimes a body: the data you are sending, like a filled-in form.

Methods

MethodMeansExample
GETRead somethingLoad a product page
POSTCreate somethingPlace an order
PUT / PATCHChange somethingUpdate your address
DELETERemove somethingDelete a comment

GET should never change data. Browsers, caches and crawlers assume they can repeat a GET safely.

Status codes

The server answers with a three-digit code. You only need to remember the first digit:

  • 2xx: it worked (200 OK, 201 Created)
  • 3xx: look somewhere else (301 Moved)
  • 4xx: the client made a mistake (400 Bad Request, 401 Unauthorized, 404 Not Found, 429 Too Many Requests)
  • 5xx: the server failed (500 Internal Server Error, 503 Service Unavailable)

The 4xx vs 5xx split matters in real systems: 5xx errors usually mean you should alert an engineer, while 4xx usually don't.

HTTPS

Plain HTTP travels as readable text. Anyone on the same Wi-Fi, or any network in between, can read and even change it.

HTTPS wraps HTTP in TLS encryption. The server shows a certificate signed by a trusted authority, the two sides agree on a secret key, and from then on everything is scrambled for outsiders. Today every site should use HTTPS; browsers warn users when a site doesn't.

Quick check

A user asks for a page that doesn't exist. Which status code should the server send?