HTTP (Hypertext Transfer Protocol) is the foundation of data communication on the web. HTTPS adds encryption via SSL/TLS.
HTTP
- Port: 80
- Stateless: each request is independent — the server doesn’t remember previous requests
- Methods: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
- Status codes: 2xx (success), 3xx (redirect), 4xx (client error), 5xx (server error)
- Headers: metadata about the request/response (Content-Type, Authorization, Cache-Control)
Statelessness
The server does not store any information about the client between requests. To maintain session state, we use:
- Cookies — server sends a token, client sends it back on every request
- JWT (JSON Web Tokens) — stateless auth tokens embedded in requests
- Sessions — server-side storage referenced by a cookie ID
HTTPS (HTTP + TLS)
- Port: 443
- Encryption: all data is encrypted between client and server
- Authentication: server presents a certificate signed by a trusted CA (Certificate Authority)
- Integrity: data cannot be modified in transit without detection
TLS Handshake
Client Server
│─── ClientHello (ciphers, TLS version) ─→
│←── ServerHello + Certificate + KeyEx ───│
│─── ClientKeyExchange + Finished ───────→│
│←── Finished ────────────────────────────│
│ Secure communication begins │
- Asymmetric encryption (RSA/ECDSA) is used to securely exchange a symmetric key
- Symmetric encryption (AES) is used for the bulk data — much faster
Common HTTP Status Codes
| Code | Meaning | Typical use |
|---|---|---|
| 200 | OK | Successful response |
| 301 | Moved Permanently | URL redirected permanently |
| 400 | Bad Request | Client sent malformed data |
| 401 | Unauthorized | Authentication required |
| 403 | Forbidden | Authenticated but not allowed |
| 404 | Not Found | Resource doesn’t exist |
| 500 | Internal Server Error | Server-side failure |
| 503 | Service Unavailable | Server overloaded or down |
Q: Why is HTTPS better than HTTP?
A: Encryption (no one can read your data in transit), Authentication (you know you’re talking to the real server, not an imposter), and Integrity (data can’t be modified in transit). HTTP sends everything in plain text.
Q: What does “stateless” mean in HTTP?
A: Each request is independent — the server doesn’t store any client context between requests. Cookies, sessions, and JWTs add state on top of the stateless protocol.
Q: Why does HTTPS use asymmetric encryption first, then switch to symmetric?
A: Asymmetric encryption (public/private key) is slow but secure for sharing a key. Symmetric encryption (same key both ways) is fast but needs both sides to have the same key. The TLS handshake uses asymmetric crypto to safely exchange a symmetric session key.
Q: What are the main HTTP methods?
A: GET (retrieve), POST (create), PUT (replace), PATCH (partial update), DELETE (remove), HEAD (headers only), OPTIONS (available methods). GET is idempotent and safe; POST is neither.
Premium Content
Unlock HTTP vs HTTPS and all premium lessons with a subscription.
From ₹199.99/year — See plans