HTTP Request Anatomy
A message sent by a client to a server, consisting of a Start Line, Headers, an Empty Line, and an optional Body.
What it is
An **HTTP Request** is a message sent by a client to a server to initiate an action or request data. It is constructed from plain text serialized over a TCP connection and consists of a **Start Line** (Method + Target + Protocol), **Headers** (metadata), an **Empty Line** (\r\n), and an optional **Body** (the payload).
Why it matters
Understanding the anatomy is critical for debugging APIs in the browser's Network tab. It allows you to know exactly how to craft fetch() calls-knowing when to put data in the URL (query parameters) versus in the Body, and how to set appropriate Content-Type headers.
How it works
At the lowest level, an HTTP/1.1 request is serialized as a plain-text stream using Carriage Return and Line Feed (\r\n) to separate lines. The server parses this stream line-by-line. When it hits the explicit empty line, it knows the headers have finished and any remaining bytes belong to the body payload.
Try it
Hover or drag the X-Ray lens over the raw HTTP request below to reveal the semantic meaning of each segment.
X-Ray Scanner: HTTP Request
Tap or hover over the raw text to analyze it.
Content-Type: application/json
Content-Length: 42
Authorization: Bearer abc123xyz
"username": "alice",
"password": "supersecret"
}
Awaiting X-Ray
Hover over a section of the raw request to decode it.
Check yourself
Pick an answer to lock it in, then read why. Getting one wrong is part of how it sticks.
Remember this
- Start Line contains the Method, Target (URL path/query), and Protocol Version.
- Headers are key-value pairs providing metadata about the request.
- The empty line explicitly separates the Headers from the Body.
- Never send a Body with a GET request-use query parameters in the URL instead.
Done with this concept?
Mark it complete to track your progress. No login needed.