Skip to content
HTTP-01Beginner3 min read

HTTP fundamentals

Requests, responses, methods, status codes and headers, with the same request written in four languages.

Updated

Every page load, API call and form submission is an HTTP exchange: a client sends a request and a server answers with a response. Once you can read both halves, most network bugs explain themselves in the browser's Network panel.

Anatomy of a request

A request has a method, a path, headers and an optional body. This is what one looks like as it travels to the server.

request.http
POST /api/lessons/42/progress HTTP/1.1
Host: strata.example
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9...
Accept: application/json

{"completed": true}

Anatomy of a response

The response starts with a status line, followed by headers and, usually, a body. The status code is the first thing to check when something goes wrong.

response.http
HTTP/1.1 201 Created
Content-Type: application/json
Cache-Control: no-store
Location: /api/lessons/42/progress

{"lesson": 42, "completed": true, "completedAt": "2026-11-29T10:24:00Z"}

Methods

MethodPurposeSafeIdempotent
GETRead a resourceYesYes
POSTCreate something or trigger an actionNoNo
PUTReplace a resource completelyNoYes
PATCHChange part of a resourceNoNot necessarily
DELETERemove a resourceNoYes

Status codes

The first digit gives the category: 2xx means success, 3xx a redirect, 4xx a problem with the request and 5xx a problem on the server. Learn the common ones by heart; they explain most bugs at a glance.

CodeMeaningTypical cause
200 OKSuccess with a bodyA normal successful request
201 CreatedA resource was createdA successful POST
204 No ContentSuccess without a bodyA successful DELETE
301 and 308Moved permanentlyA URL changed for good
304 Not ModifiedUse your cached copyA conditional request with an ETag
400 Bad RequestThe request is malformedInvalid JSON or missing fields
401 UnauthorizedNot authenticatedMissing or expired credentials
403 ForbiddenAuthenticated but not allowedA missing permission
404 Not FoundNothing at this URLA typo or a deleted resource
429 Too Many RequestsRate limitedToo many calls in a short time
500 Internal Server ErrorThe server failedAn unhandled exception
503 Service UnavailableTemporarily unavailableOverload or maintenance

Headers that matter

  • Content-Type describes the format of the body, such as application/json.
  • Accept tells the server which formats the client can read.
  • Authorization carries credentials, such as a bearer token.
  • Cache-Control decides who may cache a response and for how long.
  • ETag and If-None-Match let a client revalidate its cached copy cheaply.

The same request in four languages

Here is the request from the top of this lesson, sent from the command line and from three programming languages. Pick a tab; your choice applies to every language example on the site.

curl -X POST https://strata.example/api/lessons/42/progress \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{"completed": true}'

Summary

  • Requests carry a method, a path, headers and an optional body.
  • Status codes group into success, redirects, client errors and server errors.
  • Safe methods change nothing; idempotent methods can be repeated without harm.
  • Headers control the format, authentication and caching of every exchange.

Finished this lesson?

Mark it complete to track your progress across every track in the curriculum.