← Lessons

quiz vs the machine

Silver1040

Networking

The Anatomy of an HTTP Request

The line, headers, and body that make up every request.

4 min read · intro · beat Silver to climb

Three Parts in Order

Every HTTP request has a fixed shape that a server can parse top to bottom. It begins with a request line, followed by header fields, an empty line, and an optional body.

The Request Line

The first line names what the client wants. It has three tokens separated by spaces.

  • The method such as GET, POST, or DELETE states the intent.
  • The target is the path and query like a slash followed by a resource name.
  • The version such as HTTP one dot one tells the server which rules apply.

Headers and Body

After the request line come header fields, one per line as a name and value. A blank line marks the end of headers. For methods that send data, the body follows the blank line and its length is given by a Content Length header.

Why the Structure Matters

  • The blank line lets a parser know where headers stop and the body starts.
  • Without a length or chunked marker, the server cannot tell when the body ends.
  • A clear request line lets routers dispatch before reading the whole message.

Key idea

An HTTP request is a request line, header fields, a blank line, then an optional body, and that order lets servers parse and route messages reliably.

Check yourself

Answer to earn rating on the learn ladder.

1. What separates the headers from the body in an HTTP request?

2. Which three tokens make up the request line?