Computer Networks22 min readIntermediate

HTTP — The Language of the Web

Methods, status codes, headers, cookies, and what's new in HTTP/2 and /3.

Request / response

HTTP is a simple text-based request/response protocol. The client (browser) sends a request; the server replies with a response.

text
GET /index.html HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0
Accept: text/html

text
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 1532

<html>...</html>

Methods (verbs)

  • GET — retrieve a resource. Should have NO side effects.
  • POST — create or submit data.
  • PUT — replace a resource.
  • PATCH — partial update.
  • DELETE — remove a resource.

Status codes

  • 1xx — informational (rare).
  • 2xx — success. 200 OK, 201 Created, 204 No Content.
  • 3xx — redirect. 301 permanent, 302 temporary, 304 not modified (cache hit).
  • 4xx — client error. 400 bad request, 401 unauthorized, 403 forbidden, 404 not found, 429 too many requests.
  • 5xx — server error. 500 internal, 502 bad gateway, 503 unavailable, 504 timeout.

Cookies & sessions

HTTP is stateless — every request is independent. Cookies are how web apps remember you: the server sends `Set-Cookie: session=abc123`, your browser sends it back on every subsequent request, the server looks up `abc123` in its session store.

HTTP/2 and HTTP/3

  • HTTP/2 (2015) — binary framing, multiplexed streams over one connection, header compression. Removed the need to inline CSS / sprite images.
  • HTTP/3 (2022) — runs over QUIC (which runs over UDP). Eliminates head-of-line blocking and 0-RTT connection resumption.