What is an HTTP request? Explained with a letter and its reply
An HTTP request is the message your browser sends a server asking for something; the response is the reply, with a status code saying how it went. Explained with a letter to an order office and the stamped reply.
- Author
Umair Mateen- Published
- Reading time
- 5 min
- Category
- Engineering
In one sentence: An HTTP request is the message your browser or app sends to a website’s server asking for something, and the HTTP response is the reply that comes back, carrying a short status code that says how it went plus the page, image or data you asked for.
The everyday picture
Picture writing a letter to a shop’s order office. At the top you write one clear line: what you want done and which item it is about. Under it you add a few notes, such as which languages you can read. Sometimes you enclose something, like a filled-in order form.
The office reads your letter and writes back. Its reply starts with a stamp at the top: “Done”, “We have moved, write to this new address”, “We cannot find that item” or “Sorry, something went wrong here”. Below the stamp come its own notes, and then whatever you asked for.
That is the whole web. Every time you open a page, your browser writes a letter, called an HTTP request. The website’s server writes back, called an HTTP response. HTTP (Hypertext Transfer Protocol) is simply the agreed way to lay out those letters.
Your browser writes a request to the server. The server writes back a response whose stamp, the status code, says how it went, then your browser shows what came inside.
How it works, step by step
- The client (you, the letter writer) always writes first. The client is usually your web browser, but it can be an app or another program. The server never writes to you unless you asked.
- The request line (the first line of the letter) names a method, the item, and the HTTP version. The method says what you want done.
GETmeans “please send me this”.POSTmeans “here is something for you”, which is often how online forms are sent. - Headers and body (the notes and the enclosure): headers are short labelled notes, such as which website you are writing to. A body is optional. A
GETletter usually has none; aPOSTletter carries the form you filled in. - The status code (the stamp on the reply): the server answers with a three-digit number and a short phrase.
200 OKmeans it worked.301 Moved Permanentlymeans the item has a new address, which the reply gives.404 Not Foundmeans the server cannot find what you asked for.500 Internal Server Errormeans something broke on the server’s side. - The response body (what is inside the reply): after its own headers, the reply carries the page, picture or data. Your browser reads the stamp first, then shows you the contents.
Try it · Everyday ↔ real
Match the letter to the real thing
Switch between the two and see how each part lines up.
- You, the letter writer
- The first line of the letter
- Notes under the first line
- The enclosed order form
- The stamp on the reply
- What is inside the reply
Writing to an order office and getting a stamped reply
| Everyday | Real |
|---|---|
| You, the letter writer | The client (your browser) |
| The first line of the letter | Method, address and version |
| Notes under the first line | Request headers |
| The enclosed order form | The request body (POST) |
| The stamp on the reply | The status code |
| What is inside the reply | The response body |
Where the picture stops
- The office has no memory. HTTP is “stateless”: the server keeps nothing between two letters. To recognise you, websites hand your browser a cookie, a reference number your browser quotes on every later letter.
- Letters take days; HTTP letters usually arrive in a fraction of a second. And one web page is rarely one letter. The browser often writes many, for the page itself and each picture, style file and script it needs.
- A postcard can be read by anyone who handles it. Plain HTTP is like that. HTTPS is the encrypted version: it uses a technology called TLS to seal every letter between you and the server, which is why banks and shops use it.
Why it matters for your business
- Customers: a link that returns
404is a dead end. When you move or rename a page, a301redirect sends visitors to the new address. - Speed of fixing problems: status codes tell you where a fault sits. The 400s mean the request had a problem, like a wrong address or a missing login. The 500s mean the server failed. That one digit points your team to the right place.
- Risk: anything sent over plain HTTP, including passwords and card details, can be read on the way. Every page of your site should use HTTPS.
- Working with suppliers: APIs, the doors software uses to talk to other software, mostly run on HTTP too. Knowing the basic codes helps you read an error report from a developer or a vendor.
Try it · Myth or fact
HTTP letters: myth or fact?
Decide for yourself first, then tap each statement to check it.
0 of 4 checked
An example
Imagine a small florist that redesigns its website and renames the “Weddings” page. Old links in emails and search results now get a 404 Not Found stamp, and visitors leave. The florist asks its developer to add a 301 Moved Permanently reply on the old address. Now every letter sent to the old page gets a reply saying “we have moved, here is the new address”, and the browser follows it straight to the new page.
Frequently asked questions
What is the difference between GET and POST?
GET asks the server to send something back and should only fetch data. POST sends data to the server, such as a filled-in form, so the server may change something, like saving an order.
What does a 404 error mean?
The server cannot find what was asked for. Usually the address is wrong or the page was moved or deleted without a redirect.
What is the difference between 401 and 403?
A 401 means the server does not know who you are yet, so you need to log in. A 403 means the server knows who you are but you are not allowed to see that content.
Is HTTPS different from HTTP?
HTTPS is the same request-and-response letters, sent inside an encrypted connection using TLS. People along the way cannot read them.
Related explainers
- What is an API? Explained with a waiter in a restaurant
- What is a server? Explained with a kitchen that never closes
- What is a cookie? Explained with a cloakroom ticket
- What is encryption? Explained with a sealed envelope
The DevDrift builds web platforms and APIs that answer every letter clearly: see how.
Sources
Could you explain this to a colleague now?
Mark it and posts that mention it will show a tick. Saved in this browser only.