Course contentsShow
← Computer Science
Lesson 1518 of 2,87235. Application Layer ProtocolsFree lesson

HTTP Response Structure and Status Codes

Understanding response format and the meaning of status code categories (2xx, 3xx, 4xx, 5xx).

HTTP Response Structure and Status Codes

What you'll learn: How HTTP servers structure their responses and what the different status code ranges tell you about request outcomes.

The Response Format

When a web server answers your HTTP request, it sends back a response with three main parts:

  1. Status Line: Contains the HTTP version, a numeric status code, and a brief reason phrase (e.g., HTTP/1.1 200 OK)
  2. Headers: Metadata about the response (content type, length, caching rules, etc.)
  3. Body: The actual content—HTML, JSON, an image, or other data (optional)

Think of it like receiving a package: the shipping label tells you if delivery succeeded (status line), the packing slip has details (headers), and the box contains your item (body).

Status Code Categories

Status codes are three-digit numbers grouped by their first digit:

  • 2xx (Success): Request succeeded. Example: 200 OK means "here's your data," 201 Created means "resource created successfully."

  • 3xx (Redirection): The resource moved or you need to go elsewhere. Example: 301 Moved Permanently says "this page is now at a different URL," 304 Not Modified means "use your cached copy."

  • 4xx (Client Error): You made a mistake. Example: 404 Not Found means the URL doesn't exist, 403 Forbidden means you don't have permission.

  • 5xx (Server Error): The server failed to fulfill a valid request. Example: 500 Internal Server Error means the server crashed processing your request, 503 Service Unavailable means it's temporarily overloaded.

Key Takeaway: HTTP responses always include a status code in the 2xx–5xx range that tells you at a glance whether your request succeeded (2xx), needs redirection (3xx), had a client-side problem (4xx), or encountered a server failure (5xx).