Start With the Problem#
You type studybuddy.app/notes/priya into your browser and press Enter. Half a second later, Priya's notes
appear.
From the last two files, you know how to get bytes to 13.235.10.20:443 reliably. But:
You typed a name,
studybuddy.app. Where did the number13.235.10.20come from? Nobody told your laptop.The browser and the server are written by different companies, in different languages. What language do they use so the server understands "I want Priya's notes" and the browser understands the answer?
The server answers thousands of people. How does it know it's you on your second click, not a stranger?
Your packets pass through the café Wi-Fi, your ISP and a dozen routers. Why can't any of them read your password or change the page?
These four answers are DNS, HTTP, cookies, and HTTPS. At the end of the file (Chapter 12) you'll trace the entire journey of that Enter key using everything from all five Foundations files.
The Plain Picture#
A full postal instruction: "By courier, to Sunrise Apartments, Gate 2, Flat 304, attention: the blue folder, page 3." It says how to deliver, which building, which entrance, which flat, what exactly, and where to look inside.
The Real Name#
A URL (Uniform Resource Locator) is the full address of something on the web.
https://studybuddy.app:443/notes/priya?format=pdf&page=2#summary └─┬─┘ └─────┬──────┘└┬┘└────┬─────┘└───────┬────────┘└──┬───┘ scheme host port path query fragment
| Part | Meaning | Example |
|---|---|---|
| scheme | which protocol to use | https (or http, ws, ftp…) |
| host | which machine, by name (Ch 2) or IP address | studybuddy.app |
| port | which program (Networking 2: TCP, UDP and Ports Ch 1). Usually omitted: https means 443, http means 80 | 443 |
| path | which thing on that server | /notes/priya |
| query | extra options, as key=value pairs joined with & | format=pdf&page=2 |
| fragment | a position inside the page. Never sent to the server — only the browser uses it | #summary |
Under the Hood — percent-encoding#
URLs may only contain a limited set of ASCII characters. Anything else — spaces, & inside a value, Hindi text,
emoji — is written as % plus the hex of each UTF-8 byte (How Computers Work Ch 4.3):
space → %20
& → %26 (so "&" inside a value isn't confused with the separator)
é (C3 A9) → %C3%A9
search "chai & code" → ?q=chai%20%26%20codeThis is percent-encoding (or URL encoding). Your browser does it automatically; in code you must use your language's URL-encoding function rather than gluing strings together.
Check yourself
4 questionsName the six parts of a URL.
Show answerHide answer
Scheme, host, port, path, query, fragment.
Which part is never sent to the server?
Show answerHide answer
The fragment (after #).
What port does https://studybuddy.app/ use?
Show answerHide answer
443 (the default for https).
How is a space written inside a URL?
Show answerHide answer
%20 (in query strings, forms sometimes use +).