HTTP/HTTPS
Request/response cycle, methods, status codes, headers, and TLS encryption
What is HTTP?
The foundation of data communication on the web
HTTP (HyperText Transfer Protocol) is the foundation of data communication on the World Wide Web. When you visit a website, your browser sends an HTTP request to a server, which processes it and sends back an HTTP response.
This request-response cycle is the core of how web applications work. Understanding it deeply will help you debug issues, optimize performance, and design better APIs.
Request-Response Cycle
How client and server communicate
HTTP Request-Response Flow
Watch how data flows between client and server
GET /api/users HTTP/1.1
Host: example.com
Accept: application/json
Authorization: Bearer token123
User-Agent: Mozilla/5.0HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: max-age=3600
{"users": [...]}HTTP Methods
Different types of requests for different operations
CRUD Operations Mapping
Each method serves a specific purpose in RESTful APIs
CRUD to HTTP Methods Mapping
Why does idempotency matter?
Idempotent methods are safe to retry. If a network error occurs, you can safely resend a GET, PUT, or DELETE request without causing duplicates. POST is not idempotent - retrying might create duplicate records.
Status Codes
Server responses categorized by meaning
Common Interview Question
"What's the difference between 401 and 403?"
401 means "Who are you?" (authentication missing/invalid).
403 means "I know who you are, but you can't do this" (authorization failed).
Common Headers
Metadata that controls request and response behavior
TLS/SSL Handshake
How HTTPS establishes a secure connection
The TLS Handshake Process
Before any HTTP data is sent, client and server establish encryption
Client sends supported TLS versions, cipher suites, and a random number
Used during handshake. Public key encrypts, private key decrypts. Slower but secure for key exchange.
Used after handshake. Same key for encrypt/decrypt. Fast, efficient for data transfer.
Why HTTPS Matters
- • Encryption: Data cannot be read by eavesdroppers
- • Authentication: Proves you're talking to the real server
- • Integrity: Data cannot be modified in transit
Key Terms to Remember
Master these terms for technical interviews