Opscraft
HTTP & status codes · Lesson 1 of 9 · 4 min read

HTTP fundamentals

HTTP status codes are the first signal in almost every web incident: a spike of 502s after a deploy, 504s at exactly 60 seconds, 403s from S3, 429s from an upstream API. For a DevOps engineer the important skill isn't memorising the list — it's knowing which component generated a code (CDN, load balancer, ingress, proxy, app) and what each code implies about the failure. This topic covers HTTP fundamentals, every status class with the codes that matter, a deep troubleshooting guide for 502/503/504 on AWS and Kubernetes, and how status codes feed monitoring, SLOs and retry policies.

Request and response anatomy

Enlarge diagramREQUESTRESPONSEGET /api/orders/42 HTTP/1.1Host: shop.example.comAuthorization: Bearer eyJ…X-Request-ID: 7c1e…(no body for GET)HTTP/1.1 200 OKContent-Type: application/jsonCache-Control: no-storeContent-Length: 28{"id":42,"status":"shipped"}first line: method, path, versionfirst line: version, status code, reason
Figure 1. An HTTP request and its response. The first line carries the method and path (request) or the status code (response); headers follow; the body is optional.
Swipe sideways to see all of it, or tap to open it full screen.

The status code is a three-digit number; the first digit is the class. The reason phrase ("OK") is informational only — HTTP/2 and HTTP/3 drop it entirely.

Methods and their semantics

Method Purpose Safe Idempotent
GET Read a resource Yes Yes
HEAD GET without the body Yes Yes
OPTIONS Capabilities; CORS preflight Yes Yes
POST Create / trigger processing No No
PUT Replace a resource at a known URI No Yes
PATCH Partial update No Not necessarily
DELETE Remove a resource No Yes
  • Safe = doesn't change server state.
  • Idempotent = repeating the request has the same effect as doing it once. This decides what can be retried automatically: retrying a GET or PUT is fine; blindly retrying a POST can charge a customer twice — unless the API supports idempotency keys (Idempotency-Key header, as payment APIs do).
Enlarge diagramSafe to retry: GET, PUT, DELETECareful: POSTDoing it twice has the same effect as oncePUT /orders/42 sets the same state againDELETE twice: still deletedPOST /payments twice can charge twiceRetry only with an idempotency keyThe server stores the key and ignores repeats
Figure 2. Idempotent requests can be retried safely; a blindly retried POST can do the work twice.
Swipe sideways to see all of it, or tap to open it full screen.

Versions

  • HTTP/1.1 — text protocol, persistent connections (keep-alive), one request at a time per connection.
  • HTTP/2 — binary framing, multiplexing many streams on one TCP connection, header compression (HPACK). Used by gRPC.
  • HTTP/3 — HTTP over QUIC (UDP): no TCP head-of-line blocking, faster setup.
Enlarge diagramHTTP/1.1HTTP/2HTTP/3connection 1: req, wait, reqconnection 2: req, wait, reqconnection 3: req, wait, reqone request at a time per connection;browsers open about 6one connection, 4 streamsmany streams multiplexed on oneTCP connectionone connection, 4 streamsstreams over QUIC (UDP): nohead-of-line blocking
Figure 3. Three HTTP versions, three ways to use connections.
Swipe sideways to see all of it, or tap to open it full screen.

Headers that matter in operations

Header Why it matters
Host Virtual hosting; ingress/ALB host-based routing
X-Forwarded-For, X-Forwarded-Proto Client IP and original scheme behind proxies/LBs
X-Request-ID / traceparent Correlate a request across LB, ingress, services and logs
Location Target of redirects and newly created resources
Retry-After When to retry after 429/503
Cache-Control, ETag, Last-Modified Caching and conditional requests (304)
WWW-Authenticate Sent with 401 to say how to authenticate
Strict-Transport-Security HSTS — always use HTTPS
Allow Sent with 405 — which methods are allowed
Connection: keep-alive / Keep-Alive Connection reuse and timeouts