HTTP: Asking for a Page
In the last topic, your browser and a server held a short conversation: the browser asked for example.com, and the server sent the page back. For that to work, both sides have to speak the same language — they have to agree, in advance, exactly how a question is phrased and exactly how an answer comes back.
On the web, that shared language is HTTP — short for HyperText Transfer Protocol. A protocol is just an agreed set of rules for how two machines talk: what counts as a question, what counts as an answer, and what each part means. HTTP is the specific set of rules the web runs on, and from here on we'll just call it HTTP.
What is a protocol?
Two people can only have a useful conversation if they share a language and some basic manners — you ask, the other person answers, and you both know roughly how a request and a reply are supposed to sound. Computers need the same thing, except they need it spelled out with no room for guessing.
A protocol is that spelled-out agreement. It fixes the exact format of a message so the receiving machine knows where the question ends, what was actually asked, and how to phrase the reply. HTTP is one such protocol — the one browsers and web servers use to trade pages.
The request: "please give me this"
A conversation over HTTP always starts with the browser sending a request. The core of that request is short: a verb and an address. The most common verb is GET, which means exactly what it sounds like — "give me this." The address says which thing: the home page, a specific article, an image.
So when you open example.com, your browser sends, in effect, "GET the home page of example.com." That is the whole question. There are other verbs for other actions — sending data when you submit a form, for instance — but reading a page is always a GET.
The response: the page, plus a status
The server answers with a response, and the response has two parts. The first is a status — a short code that says how the request went. The second is the content: usually the page you asked for, though it might be an image, some data, or nothing at all.
The status you never notice is 200, which simply means "here it is." The status everyone has met is 404, which means "I looked, and there's no such page here." The key point is that 404 is still an answer — the server received your request, understood it, and replied. It just didn't have the thing you named.
Picture ordering at a counter with a fixed, polite script. You say "I'd like the daily special, please." The reply is either "here you go" or "sorry, we're out of that today." Either way you got a clear answer in a phrasing you both expected — and "we're out" is not the same as the counter being closed. HTTP works the same way: 200 is "here you go," 404 is "we're out of that page," and both mean the server was open and listening.
Why the rules have to match
The whole arrangement only works because both sides agree on the rules ahead of time. The browser phrases its request in exactly the form HTTP defines, and the server replies in exactly the form HTTP defines, so neither has to guess what the other meant.
If even one side broke the rules — sent a request in some made-up format, or answered in a shape the browser couldn't read — the page simply wouldn't load. A shared protocol is what lets a browser made by one company talk to a server run by a complete stranger, anywhere in the world, and have it just work.
- "A 404 means my internet is broken." The opposite — your request reached the server and it answered. It just didn't have that particular page. A broken connection means no answer at all.
- "HTTP is the website." HTTP is only the language for asking and answering. The website is the content that travels in those answers; HTTP is the agreed way it's carried.
- "Every response is a web page." A response can carry a page, but it can just as easily carry an image, raw data, or only a status with no content — like a 404.
- "A status code only ever means an error." Every response carries a status, including the successful ones. The quiet 200 ("here it is") rides along on every page that loads fine.
- Every time you load a page, submit a form, or open an app, an HTTP request and response are doing the work underneath — this is the web's basic motion.
- Status codes like 404 and 200 turn up constantly when anything goes wrong online; knowing 404 means "answered, but not found" tells you the connection is fine.
- APIs — the way apps and services request data from each other — are built on these same HTTP requests and responses, so this idea reappears across web and cloud work.
- Understanding that a protocol is a shared, strict agreement explains how machines built by total strangers manage to work together at all.
Knowledge Check
What is HTTP, in plain terms?
- The shared set of rules a browser and server use to ask for and send pages
- The actual page content itself, including all of its text, images, and layout
- The system that translates a site's name into the server's numeric address
- The always-on computer in a data center that stores and runs the website
You open a link and the browser shows a 404. What does that actually tell you?
- The server answered, but it has no page at the address you asked for
- Your internet connection has dropped and no request reached the server
- The page loaded fine, but one of its images failed to appear
- The site's name could not be translated into a server address
A browser sends a GET request for example.com. What is it asking the server to do?
- Send back the page at that address
- Save some new data onto the server's storage
- Look up the numeric address that the name points to
- Delete the existing page so a new one can replace it
Why must the browser and server both follow HTTP's exact rules?
- So each side can understand the other without having to guess the format
- Because following the rules makes the internet connection physically faster
- Because the rules are what keep the contents of every page fully private
- Because every website invents its own private rules that only it can read
You got correct