HTTP — Asking and Answering
Packets can carry anything, so the browser and the server need an agreed way to say "please send me the menu page" and "here it is". That agreement is HTTP, the HyperText Transfer Protocol. Every page, image, stylesheet and script on the bakery site arrives through an HTTP conversation.
The rule
The browser asks with a method and a path; the server answers with a status.
An HTTP request is plain, readable text. Opening the bakery's menu sends something like this:
GET /menu HTTP/1.1
Host: crumbbakery.com
Accept: text/html- Method (
GET): what you want done.GETfetches,POSTsends new data such as an order form,PUTandPATCHupdate,DELETEremoves. - Path (
/menu): which thing on the server. - Headers (
Host,Accept): extra details, one per line, asName: value.
The response comes back in the same shape:
HTTP/1.1 200 OK
Content-Type: text/html
<!DOCTYPE html>
<html>...the menu page...</html>The number is the status code, and its first digit tells you the story:
| Class | Meaning | Examples |
|---|---|---|
| 2xx | It worked | 200 OK, 201 Created |
| 3xx | Look somewhere else | 301 Moved Permanently, 304 Not Modified |
| 4xx | The request was wrong | 404 Not Found, 401 Unauthorized, 403 Forbidden |
| 5xx | The server failed | 500 Internal Server Error, 503 Service Unavailable |
HTTP is stateless: each request stands alone, and the server does not automatically remember the previous one. Sites remember who you are by sending something with every request, most often a cookie.
HTTPS is the same conversation wrapped in encryption (TLS), so nobody on the path can read or quietly change it. Today every public site should use it.
The shortcut
Read any request or response with the "verb, noun, verdict" pattern: the method is the verb, the path is the noun, the status code's first digit is the verdict. 4 means "you asked wrongly", 5 means "I broke".
Verb and noun
The order form sends
POST /orders: create something new in the orders collection.
Watch for the classic mix-up: a 404 is the client's problem (wrong address), while a 500 means the server's own code crashed. Fixing a 500 by retyping the URL will not help.
Drills
Answer fast — trust the rule.
Which method should the bakery's order form use to send a new order?
A visitor types crumbbakery.com/menuu and gets a status in the 400s. Most likely which one?
What does a status code starting with 5 tell you?
HTTP is stateless. How does a site still know you are logged in on your next request?
Remember
- The browser asks with a method and a path; the server answers with a status.
- Verb, noun, verdict: 2 worked, 3 look elsewhere, 4 you asked wrongly, 5 the server broke.
- Trap: HTTP forgets between requests, so cookies carry who you are.
