HTTP & DNS
Basic Working Mechanisms of Web Protocols
HTTP & DNS (Quick Summary)
1. HTTP (HyperText Transfer Protocol)
Operates on L7 (Application Layer) and is the main protocol used on the World Wide Web in a Request-Response model.
- Stateless: The server does not remember the state of the client from previous requests (hence
CookiesorTokensmust be used for authentication). - HTTP Methods:
GET: Request data (Read)POST: Send data to create something new (Create)PUT/PATCH: Update data (Update)DELETE: Delete data (Delete)
- Main Status Codes:
2xx: Success (e.g.,200 OK,201 Created)3xx: Redirection (e.g.,301 Moved Permanently)4xx: Client Error (e.g.,400 Bad Request,401 Unauthorized,404 Not Found)5xx: Server Error (e.g.,500 Internal Server Error,502 Bad Gateway)
2. DNS (Domain Name System)
The phonebook of the Internet.
- Function: Translates Human-Readable Domains (e.g.,
google.com) into IP Addresses (e.g.,142.250.190.46) that computers use to communicate via L3 (Network Layer). - DNS Resolution Flow:
- Browser Cache (checks local machine first)
- OS Cache (
hostsfile) - Router Cache
- ISP Recursive DNS Server
- Queries Root Server -> TLD Server (
.com) -> Authoritative Server until the IP is returned