Skip to the content ForoHackers
Log inJoin

HTTP: start here

HTTP
#3425 · · Quote · Report

HTTP is the protocol of the web: a client sends a request naming a resource and a method, and a server sends back a status, headers and usually a body. It is simple, text-shaped at its core and stateless, and nearly every web service, API and browser conversation rests on it.

Key concepts

  • Request and response: a method, a URL, headers and an optional body go out; a status code, headers and a body come back.
  • Methods and their meaning: GET reads, POST submits, PUT replaces, DELETE removes; some are safe or idempotent.
  • Status codes: families for success, redirection, client error and server error.
  • Headers: metadata for content type, caching, cookies, authentication and cross-origin rules.
  • TLS: HTTPS wraps HTTP in an encrypted, authenticated channel; use it everywhere.

Vocabulary

  • Idempotent: repeating the request has the same effect as sending it once.
  • Cache-Control: the header family that tells caches how long a response stays fresh.
  • Cookie: a small value the server asks the client to send back, used to keep sessions.
  • Keep-alive and multiplexing: reusing a connection for many requests instead of opening one for each.

What to study, in order

  1. Send a request by hand with a command-line client, and read the raw headers of the reply.
  2. Capture the same exchange in the browser's network panel and in a packet capture tool, on your own traffic.
  3. Learn the status codes you meet daily, and what each tells a client to do.
  4. Implement caching with validators and see a conditional request return a not-modified answer.
  5. Read about how newer versions of the protocol change the transport but not the meaning.

Related tags

#tcp-ip #web-standards #web-performance #api-design

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply