Topic 07

The Request: Method, Headers, Body

HTTP

When the Tandem app checks how many bikes are at Old Market, something leaves the phone. It is worth pausing on what that something actually is — because most people imagine streams of machine code, unreadable by design. The truth is better: what leaves is a short piece of plain text called a request, a handful of lines long, and you can read every character of it.

Seeing that — that the whole mysterious exchange is a few lines of readable text — is where the fear starts dying. This page shows a complete request and names its three parts: the request line, the headers, and the body. Every request you will ever send or see has exactly this shape.

A complete request, exactly as it leaves the machine
GET /v1/stations/st_014 HTTP/1.1
Host: api.tandem.example
Accept: application/json
User-Agent: TandemApp/4.2

Four lines of text. That is the entire request the app sends to ask about Old Market. Now, part by part.

The Request Line: What You Want, and Where

The first line does the heavy lifting: GET /v1/stations/st_014 HTTP/1.1. Three pieces. The method — here GET — is the verb, what kind of act this is; GET means "give me this, change nothing," and the verbs get their own page two topics from now. Then the path — the room, straight from the last page. Then the HTTP version the sender speaks. One line, and the server already knows what is being asked of it.

Headers: Notes on the Envelope

The lines after the request line are headers — one per line, each in the form Name: value. Think of them as handling notes written on the outside of an envelope: who is sending this, what form of answer they can accept, how the contents are packed. In the example: Host names the building (the URL's host, restated inside the request), Accept says "I would like the answer as JSON, please" — JSON being the data format Chapter 4 teaches — and User-Agent is the sender introducing itself.

Most headers are optional — Host is the required exception — but one of them will shortly become the difference between locked out and let in: from Chapter 5 on, your key travels in a header called Authorization, on every single request. Headers are where the important envelope-notes go, and the habit of reading them starts now.

The Body: the Parcel, When There Is One

Notice what the example does not have: a body. A body is content carried inside the request — an actual parcel, not just notes on the envelope. A GET carries none, because "give me this" needs no cargo; the ask is the label. Requests that send something in — creating a reservation, submitting a form — carry their cargo in the body, usually as JSON, with a header called Content-Type announcing the format. You will send your first body in Chapter 3, and it will feel exactly like what it is: filling in one small form.

Read One Whole Request

Go back to the four lines above and read them once more, slowly. A verb, a room, a dialect. A building name. A preference. A signature. Nothing hidden, nothing binary, nothing you could not have typed yourself. When something goes wrong in Chapter 7 and a support engineer asks Vera "what did you send?", this page is what makes that question answerable — because a request is not an event that happens to you. It is a document you can show.

The three bands of every request
Request line
GET /v1/stations/st_014 HTTP/1.1 — verb, room, dialect
Headers
Name: value notes on the envelope — and, from Chapter 5, the key
Body
the parcel, when there is one — a GET travels empty on purpose
Common Confusions
  • "Requests are binary machine code." HTTP requests are human-readable text — that is why the tools in Chapter 3 can show them to you verbatim, and why you will be able to write one by hand.
  • "Headers are advanced options I can safely ignore." One header is the difference between a locked door and an open one from Chapter 5 onward. Headers are load-bearing; the reading habit starts now.
  • "Every request carries data in a body." GET asks and carries nothing — the ask is the label on an empty envelope. Bodies belong to requests that send something in.
  • "The Host header is redundant — the address already said it." It looks that way, but it is the one header HTTP requires: one server at one address usually answers for many names, and the Host line is how it knows which one you meant. Leave it off and you get a 400. (The full story is a Networking Deep Dive one.)
Why It Matters
  • Everything the browser's developer panel shows in Chapter 3, and everything the curl command sends, is exactly this text. Learn the shape once, recognize it in every tool forever.
  • A request is a document, not an event. "What did you send?" — the first question in every support conversation — has an answer you can literally paste.

Knowledge Check

What are the three parts of an HTTP request?

  • The scheme, the host, and the query string
  • The request line, the headers, and the body
  • The client, the server, and the road between them
  • The status line, the verdict, and the answer

Why does a GET request have no body?

  • Because the body gets stripped out automatically by the network to keep things efficient
  • Because bodies are only ever used for sending large amounts of data
  • Because the ask itself is the whole message, with no cargo to carry
  • Because GET requests are not allowed to carry headers either

What is a header, structurally?

  • The first line of the request, naming the verb and the path
  • A Name: value line on the envelope, carrying context about the request
  • A block of content carried inside the request, usually written as JSON
  • A label the server attaches to your request when it arrives

You got correct