HTTP/HTTPS
HTTP (HyperText Transfer Protocol) is the web's core protocol: every page, image, and API call between your browser and a server speaks this language. HTTPS is the same language, encrypted.
01The request–response model
In HTTP, the client always starts the conversation:
code
Browser → HTTP Request → Server
Browser ← HTTP Response ← Server
A server never pushes data to you unprompted — behind every response there is a request.
02HTTP methods
| Method | Use | Example |
|---|---|---|
| GET | Fetch data | Viewing a page |
| POST | Send data | Submitting a form |
| PUT | Update | Editing a profile |
| DELETE | Remove | Deleting an account |
| HEAD | Headers only | Checking a file's size |
03Anatomy of a request
code
GET /index.html HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0
Accept: text/html
Cookie: session=abc123
04Anatomy of a response
code
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 1234
<html>...</html>
The number on the first line sums up the request's fate:
05HTTP status codes
| Code | Meaning | Description |
|---|---|---|
| 200 | OK | Success |
| 301 | Moved | Permanent redirect |
| 302 | Found | Temporary redirect |
| 400 | Bad Request | Malformed request |
| 401 | Unauthorized | Authentication required |
| 403 | Forbidden | Access denied |
| 404 | Not Found | Doesn't exist |
| 500 | Server Error | Server-side failure |
Rule of thumb: 2xx success, 3xx redirection, 4xx your fault, 5xx the server's fault.
06HTTPS = HTTP + TLS
HTTPS is HTTP traffic encrypted with TLS:
| HTTP | HTTPS |
|---|---|
| Port 80 | Port 443 |
| Plaintext — anyone on the path can read it | Encrypted — only the two ends can read it |
http:// | https:// |
How HTTPS gets established
- TLS handshake — client and server agree on encryption methods
- Certificate validation — the server proves its identity
- Key exchange — a session-specific encryption key is created
- Encrypted traffic — all HTTP now flows encrypted
07Summary
- HTTP = the web's request–response protocol
- HTTPS = HTTP + TLS encryption (port 443)
- GET fetches, POST sends
- 2xx success, 3xx redirect, 4xx client error, 5xx server error