HTTP Response Anatomy
A message sent by a server back to a client, consisting of a Status Line, Headers, an Empty Line, and an optional Body.
What it is
An **HTTP Response** is the message sent by a server back to a client in reply to an HTTP Request. It consists of a **Status Line** (Protocol + Status Code + Status Text), **Headers** (metadata), an **Empty Line** (\r\n), and an optional **Body** (the payload).
Why it matters
Mastering the HTTP response is critical for handling errors (status codes), checking content types so the browser knows how to parse data, and configuring caching directives for optimization.
How it works
The server serializes its output as a continuous plain-text stream (in HTTP/1.1). It outputs the Status Line first, followed by each Header. Crucially, it then sends an empty blank line to signal that the metadata is finished. Everything following that empty line is treated as the raw bytes of the Body.
Try it
Tap the blocks in the raw HTTP response below to dissect the plain-text anatomy.
Tap any block below to dissect it.
{
"success": true,
"data": {
"user_id": 1042,
"role": "admin"
}
}Check yourself
Pick an answer to lock it in, then read why. Getting one wrong is part of how it sticks.
Remember this
- Status Line contains Protocol Version, Status Code (e.g., 200, 404), and Status Text.
- Headers provide metadata like Content-Type and Cache-Control.
- The empty line explicitly separates the Headers from the Body.
- fetch() does not throw an error on 404 or 500 status codes; you must check response.ok.
Done with this concept?
Mark it complete to track your progress. No login needed.