जब आप browser में कोई website open करते हैं, DNS domain को server के IP address तक पहुँचाने में help करता है।
लेकिन उसके बाद एक important सवाल आता है:
Browser और server आपस में बात कैसे करते हैं?
यहीं पर HTTP और HTTPS काम आते हैं।
Simple flow:
Domain
↓
DNS
↓
IP Address
↓
HTTP / HTTPS
↓
Server
↓
Response
↓
Browser
इस cheat sheet में हम HTTP, HTTPS, request, response, methods, status codes, headers, cookies, HTTPS security और practical debugging को आसान Hinglish में समझेंगे।
HTTP क्या है?#
HTTP का full form है — HyperText Transfer Protocol.
HTTP एक protocol है जिसका use client और server के बीच communication के लिए किया जाता है।
Example:
Browser → HTTP Request → Server
Browser ← HTTP Response ← Server
जब आप website खोलते हैं, browser server को request भेजता है।
Server request process करके response भेजता है।
HTTP को आसान भाषा में समझें#
मान लीजिए आप restaurant में जाते हैं।
आप कहते हैं:
“Mujhe एक Pizza चाहिए।”
यह आपकी request है।
Restaurant pizza देता है।
यह response है।
Internet में:
Client
↓
Request
↓
Server
↓
Response
↓
Client
यही basic client-server communication है।
Client और Server क्या हैं?#
Client
जो request भेजता है।
Examples:
- Web Browser
- Mobile App
- Frontend JavaScript
- API Client
Server
जो request receive करके response देता है।
Examples:
- Node.js Server
- PHP Server
- Nginx
- Apache
- API Server
Simple model:
Client → Request → Server
Client ← Response ← Server
HTTP Request क्या है?#
जब client server से कुछ मांगता है, तो वह HTTP Request भेजता है।
Example:
GET /products HTTP/1.1
Host: example.com
Request में कई important चीजें हो सकती हैं:
HTTP Method
URL / Path
Headers
Body
HTTP Request के Main Parts#
एक request को broadly ऐसे समझें:
Request
├── Method
├── URL / Path
├── Headers
└── Body
Example:
POST /api/login HTTP/1.1
Host: example.com
Content-Type: application/json
{
"email": "user@example.com",
"password": "password"
}
HTTP Method क्या है?#
HTTP Method बताता है कि client server से क्या operation करना चाहता है।
सबसे commonly used methods:
GET
POST
PUT
PATCH
DELETE
GET#
GET का use data retrieve करने के लिए किया जाता है।
Example:
GET /products
Meaning:
Server से products की information चाहिए।
Another example:
GET /users/10
इसका मतलब हो सकता है:
User ID 10 की information चाहिए।
POST#
POST का use server को नया data भेजने या कोई operation trigger करने के लिए commonly किया जाता है।
Example:
POST /users
Request body:
{
"name": "Rahul",
"email": "rahul@example.com"
}
Server इस data के basis पर नया user create कर सकता है।
PUT#
PUT का use resource को update या replace करने के लिए किया जा सकता है।
Example:
PUT /users/10
{
"name": "Rahul Sharma",
"email": "rahul@example.com"
}
PATCH#
PATCH का use resource के कुछ specific fields update करने के लिए commonly किया जाता है।
Example:
PATCH /users/10
{
"name": "Rahul Sharma"
}
यह केवल required field update कर सकता है।
DELETE#
DELETE का use resource delete करने के लिए किया जाता है।
Example:
DELETE /users/10
Meaning:
User ID 10 को delete करना है।
HTTP Methods Quick Reference#
| Method | Common Purpose |
|---|---|
| GET | Data retrieve करना |
| POST | Data create/send करना |
| PUT | Resource update/replace करना |
| PATCH | Partial update |
| DELETE | Resource delete करना |
HTTP Response क्या है?#
Server request process करने के बाद client को response देता है।
Example:
HTTP/1.1 200 OK
Content-Type: application/json
{
"message": "Success"
}
Response में commonly ये चीजें होती हैं:
Status Code
Headers
Body
HTTP Status Code क्या है?#
Status code बताता है कि request का result क्या हुआ।
Examples:
200 → Success
404 → Not Found
500 → Server Error
Status codes generally 5 categories में होते हैं:
1xx → Informational
2xx → Success
3xx → Redirection
4xx → Client Error
5xx → Server Error
1xx Status Codes#
ये informational responses होते हैं।
Example:
100 Continue
Beginners के लिए सबसे important बात:
1xx = Information
2xx Status Codes#
ये generally successful requests को represent करते हैं।
200 OK
Request successfully process हुई।
200 OK
201 Created
New resource create हुआ।
201 Created
204 No Content
Request successful थी लेकिन response body में content नहीं है।
204 No Content
याद रखें:
2xx = Success
3xx Status Codes#
ये redirection से related होते हैं।
301 Moved Permanently
Resource permanently दूसरे URL पर move हुआ है।
302 Found
Temporary redirection के लिए commonly used status code।
304 Not Modified
Client के पास cached version अभी भी valid हो सकता है, इसलिए server नया content भेजने की जरूरत नहीं समझता।
3xx = Redirection
4xx Status Codes#
ये client-side/request-related errors को indicate करते हैं।
400 Bad Request
Request invalid या malformed हो सकती है।
400 Bad Request
401 Unauthorized
Authentication required है या authentication credentials acceptable नहीं हैं।
401 Unauthorized
403 Forbidden
Server ने request समझी, लेकिन access allowed नहीं है।
403 Forbidden
404 Not Found
Requested resource नहीं मिला।
404 Not Found
405 Method Not Allowed
Requested HTTP method उस resource के लिए allowed नहीं है।
405 Method Not Allowed
याद रखें:
4xx = Request / Client Side Problem
5xx Status Codes#
ये server-side errors को indicate करते हैं।
500 Internal Server Error
Server पर unexpected error हुआ।
500 Internal Server Error
502 Bad Gateway
Server/gateway को upstream server से invalid response मिला हो सकता है।
503 Service Unavailable
Server temporarily available नहीं है या service handle नहीं कर पा रही।
504 Gateway Timeout
Gateway/proxy को upstream server से समय पर response नहीं मिला।
याद रखें:
5xx = Server Side Problem
HTTP Status Code Cheat Sheet#
| Code | Meaning |
|---|---|
| 200 | OK |
| 201 | Created |
| 204 | No Content |
| 301 | Moved Permanently |
| 302 | Found / Temporary Redirect |
| 304 | Not Modified |
| 400 | Bad Request |
| 401 | Unauthorized |
| 403 | Forbidden |
| 404 | Not Found |
| 405 | Method Not Allowed |
| 500 | Internal Server Error |
| 502 | Bad Gateway |
| 503 | Service Unavailable |
| 504 | Gateway Timeout |
HTTP Headers क्या हैं?#
Headers request या response के बारे में additional information provide करते हैं।
Example:
Content-Type: application/json
इसका मतलब है कि body में JSON data है।
कुछ common headers:
Content-Type
Authorization
Accept
Cache-Control
Cookie
Set-Cookie
User-Agent
Location
Content-Type#
Content-Type बताता है कि request या response body का data किस format में है।
JSON:
Content-Type: application/json
HTML:
Content-Type: text/html
Plain text:
Content-Type: text/plain
Form data:
Content-Type: application/x-www-form-urlencoded
Authorization Header#
API authentication में commonly use होता है।
Example:
Authorization: Bearer YOUR_TOKEN
इसका मतलब यह नहीं कि हर API इसी exact authentication method का use करती है, लेकिन Bearer tokens काफी common हैं।
Accept Header#
Client server को बता सकता है कि वह किस प्रकार का response accept कर सकता है।
Example:
Accept: application/json
User-Agent#
User-Agent client/software के बारे में information provide कर सकता है।
Example:
User-Agent: Mozilla/5.0
Browsers commonly User-Agent information send करते हैं।
HTTP Request Body#
Request body में client server को data भेज सकता है।
Example:
POST /api/users
Content-Type: application/json
{
"name": "Rahul",
"age": 25
}
GET requests में generally data URL/query parameters में भेजा जा सकता है, जबकि POST/PUT/PATCH requests में body commonly use होती है।
Query Parameters#
URL में ? के बाद query parameters आ सकते हैं।
Example:
https://example.com/products?page=2&limit=10
यहाँ:
page = 2
limit = 10
Query parameters का use filtering, pagination, search आदि के लिए commonly होता है।
Example:
/products?category=mobile
Path Parameters#
URL path में resource identify करने के लिए values use की जा सकती हैं।
Example:
/users/25
यहाँ:
25
user ID हो सकती है।
Compare करें:
/users/25
vs
/users?id=25
दोनों अलग URL designs हैं।
HTTP और HTTPS में Difference#
सबसे important difference:
HTTP
↓
Unencrypted communication
HTTPS
↓
Encrypted communication
HTTPS का मतलब है:
HTTP Secure
HTTPS में HTTP communication को TLS के जरिए secure किया जाता है।
HTTPS क्यों जरूरी है?#
अगर website HTTPS use नहीं करती, तो network पर communication को protect करने के लिए modern encryption layer नहीं होती।
HTTPS तीन important security goals provide करने में मदद करता है:
Confidentiality
Integrity
Authentication
Confidentiality
Communication को unauthorized parties से छिपाने में help करता है।
Integrity
Data रास्ते में modify हुआ या नहीं, इसे detect करने में help करता है।
Authentication
Certificate-based trust mechanism के जरिए server identity verify करने में help करता है।
HTTP vs HTTPS#
| HTTP | HTTPS |
|---|---|
| HTTP protocol | HTTP over TLS |
| Encryption नहीं | TLS encryption |
| Security कम | Security ज्यादा |
URL http:// | URL https:// |
| Sensitive data के लिए unsuitable | Sensitive data के लिए preferred |
आज modern websites के लिए HTTPS standard practice है।
HTTPS कैसे काम करता है?#
Simplified flow:
Browser
↓
HTTPS Connection
↓
TLS Handshake
↓
Certificate Verification
↓
Secure Session
↓
HTTP Request / Response
TLS handshake के दौरान browser और server secure communication establish करते हैं।
इसके बाद HTTP data encrypted connection के through transfer होता है।
SSL और TLS#
आपने अक्सर सुना होगा:
SSL Certificate
लेकिन modern HTTPS security में TLS protocol use होता है।
SSL एक older technology है।
Simple याद रखें:
HTTPS
↓
TLS
↓
Secure HTTP Communication
आज नए systems में TLS terminology prefer की जाती है।
HTTPS Certificate क्या है?#
HTTPS website के पास generally a TLS certificate होता है।
Example:
https://example.com
Browser certificate information check करता है और secure connection establish करने में इसका use करता है।
Certificate domain identity और cryptographic information से related होता है।
HTTP और HTTPS Ports#
Common default ports:
HTTP → 80
HTTPS → 443
Example:
http://example.com
↓
Port 80
https://example.com
↓
Port 443
हालांकि applications custom ports पर भी run कर सकती हैं।
HTTP Request का Complete Example#
Browser request:
GET /products HTTP/1.1
Host: example.com
Accept: application/json
User-Agent: Mozilla/5.0
Server response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"products": [
{
"id": 1,
"name": "Laptop"
}
]
}
Flow:
Browser
↓
GET /products
↓
Server
↓
200 OK
↓
JSON Data
↓
Browser
API और HTTP#
Modern applications में frontend और backend अक्सर HTTP-based APIs के through communicate करते हैं।
Example:
React App
↓
GET /api/products
↓
Backend
↓
Database
↓
JSON Response
↓
React App
Response:
{
"products": [
{
"id": 1,
"name": "Laptop"
}
]
}
REST API और HTTP Methods#
REST-style APIs में HTTP methods को resources के साथ commonly map किया जाता है।
Example:
| Operation | Method | Endpoint |
|---|---|---|
| List users | GET | /users |
| Get user | GET | /users/10 |
| Create user | POST | /users |
| Update user | PUT | /users/10 |
| Partial update | PATCH | /users/10 |
| Delete user | DELETE | /users/10 |
यह एक common REST pattern है; actual API design project के अनुसार अलग हो सकता है।
Cookies क्या हैं?#
Cookies browser में small pieces of data store करने के लिए commonly use होती हैं।
Common use cases:
- Login/session
- Preferences
- Tracking
- Shopping cart
- Authentication state
Server cookie set कर सकता है:
Set-Cookie: session_id=abc123
Browser बाद की requests में cookie भेज सकता है:
Cookie: session_id=abc123
Cache-Control Header#
Caching behavior control करने के लिए Cache-Control header important है।
Example:
Cache-Control: max-age=3600
यह caching policy define कर सकता है।
Caching website performance improve करने में help कर सकती है।
HTTP Redirect#
Server client को दूसरे URL पर redirect कर सकता है।
Example:
HTTP/1.1 301 Moved Permanently
Location: https://example.com/new-page
Browser Location header के basis पर new URL request कर सकता है।
Commonly:
301 → Permanent redirect
302 → Temporary redirect
Browser DevTools में HTTP कैसे देखें?#
Chrome/Edge जैसे browsers में:
Right Click
↓
Inspect
↓
Network
अब page reload करें।
आप requests देख सकते हैं:
Document
CSS
JavaScript
Images
Fonts
Fetch/XHR
किसी request पर click करने पर आपको information मिल सकती है:
Headers
Payload
Preview
Response
Timing
यह frontend debugging के लिए बहुत useful है।
Network Tab में क्या Check करें?#
अगर API काम नहीं कर रही है, तो सबसे पहले देखें:
☐ Request URL
☐ HTTP Method
☐ Status Code
☐ Request Headers
☐ Request Payload
☐ Response
☐ Response Headers
☐ Timing
Example:
POST /api/login
Status: 401
इससे पता चलता है कि request server तक पहुँची, लेकिन authentication-related problem हो सकती है।
Common HTTP Errors#
400
Bad Request
Request format/data check करें।
401
Unauthorized
Authentication/token check करें।
403
Forbidden
Permissions/access check करें।
404
Not Found
URL/endpoint check करें।
500
Internal Server Error
Backend/server logs check करें।
502
Bad Gateway
Proxy/gateway और upstream server check करें।
503
Service Unavailable
Server/service availability check करें।
504
Gateway Timeout
Upstream response delay/network/server issue check करें।
HTTP Troubleshooting Flow#
API या website problem होने पर:
1. URL Check
↓
2. DNS Check
↓
3. Connection Check
↓
4. HTTP Method Check
↓
5. Request Headers
↓
6. Request Body
↓
7. Status Code
↓
8. Response Body
↓
9. Server Logs
यह flow debugging को systematic बनाता है।
HTTP और DNS का Connection#
DNS और HTTP अलग concepts हैं, लेकिन website open करते समय दोनों साथ काम करते हैं।
Basic flow:
Browser
↓
DNS Lookup
↓
IP Address
↓
TCP Connection
↓
TLS Handshake
↓
HTTP Request
↓
HTTP Response
↓
Website
HTTPS में TLS step आता है।
Common Mistakes#
Mistake 1: 404 को Server Down समझना
404 का मतलब generally requested resource नहीं मिला।
Server completely down है, ऐसा जरूरी नहीं।
Mistake 2: 401 और 403 को Same समझना
Simple difference:
401 → Authentication problem
403 → Access forbidden
Mistake 3: HTTP और HTTPS को केवल URL का Difference समझना
HTTPS केवल https:// लिखने से नहीं बनता।
HTTPS में TLS-based secure connection शामिल होती है।
Mistake 4: 500 का मतलब हमेशा Frontend Bug समझना
500 server-side error indicate करता है।
Backend code, dependencies, database, configuration या server environment check करना पड़ सकता है।
Mistake 5: Browser में Page Open हो रहा है तो API भी सही होगी
Website का frontend load हो सकता है, लेकिन API request fail हो सकती है।
इसलिए DevTools → Network में actual API request check करें।
HTTP / HTTPS Quick Reference#
HTTP
→ HyperText Transfer Protocol
HTTPS
→ HTTP over TLS
HTTP Port
→ 80
HTTPS Port
→ 443
GET
→ Retrieve data
POST
→ Create/send data
PUT
→ Replace/update resource
PATCH
→ Partial update
DELETE
→ Delete resource
2xx
→ Success
3xx
→ Redirect
4xx
→ Client/request error
5xx
→ Server error
Important Status Codes याद रखें#
200 → OK
201 → Created
204 → No Content
301 → Permanent Redirect
302 → Temporary Redirect
304 → Not Modified
400 → Bad Request
401 → Unauthorized
403 → Forbidden
404 → Not Found
405 → Method Not Allowed
500 → Internal Server Error
502 → Bad Gateway
503 → Service Unavailable
504 → Gateway Timeout
याद रखने की Trick
2xx = Success
3xx = Redirect
4xx = You/Request side
5xx = Server side
Knowledge Check#
1. HTTP का full form क्या है?
A. HyperText Transfer Protocol
B. High Transfer Text Protocol
C. Hyper Transfer Technology Protocol
D. Host Transfer Protocol
Answer: A
2. HTTPS में security के लिए कौन सा protocol use होता है?
A. FTP
B. TLS
C. DNS
D. SSH
Answer: B
3. GET method का common purpose क्या है?
A. Data retrieve करना
B. Server delete करना
C. DNS configure करना
D. SSL install करना
Answer: A
4. 404 का क्या मतलब है?
A. Server Started
B. Unauthorized
C. Not Found
D. Bad Gateway
Answer: C
5. 500 status code किस type की problem indicate करता है?
A. Client-side
B. Server-side
C. DNS-only
D. Browser cache-only
Answer: B
6. HTTPS का default port कौन सा है?
A. 21
B. 22
C. 80
D. 443
Answer: D
Practical Exercises#
Exercise 1: Browser Network Tab
किसी website को open करें।
Right Click
→ Inspect
→ Network
→ Reload
एक request select करें और देखें:
Method
Status Code
Request URL
Headers
Response
Timing
Exercise 2: GET Request
Terminal में try करें:
curl https://example.com
यह server से response प्राप्त करने का simple तरीका है।
Exercise 3: Headers देखें
curl -I https://example.com
यह response headers inspect करने में useful है।
Exercise 4: HTTP Status Check करें
curl -I https://example.com
Response में देखें:
HTTP/...
200
या website के अनुसार कोई दूसरा status code।
Exercise 5: API Request समझें
किसी public API documentation से एक GET endpoint चुनें और identify करें:
HTTP Method
URL
Headers
Response Status
Response Body
Summary#
इस HTTP / HTTPS Cheat Sheet में हमने सीखा:
- HTTP क्या है
- HTTPS क्या है
- Client और Server
- Request और Response
- HTTP Methods
- GET
- POST
- PUT
- PATCH
- DELETE
- HTTP Status Codes
- Request/Response Headers
- Request Body
- Query Parameters
- Cookies
- Cache-Control
- Redirects
- HTTPS और TLS
- HTTP/HTTPS ports
- APIs और REST
- Browser Network DevTools
- HTTP troubleshooting
सबसे important mental model:
Client
↓
HTTP Request
↓
Server
↓
HTTP Response
↓
Client
और complete website flow:
Domain
↓
DNS
↓
IP Address
↓
TCP Connection
↓
TLS (HTTPS)
↓
HTTP Request
↓
Server
↓
HTTP Response
↓
Browser
आगे क्या सीखें?#
अब तक हमने:
Computer Fundamentals
↓
Terminal / Shell
↓
Git
↓
GitHub
↓
Internet Fundamentals
↓
DNS
↓
HTTP / HTTPS
सीख लिया है।
अगला topic होगा:
Browser DevTools Cheat Sheet
इसमें हम सीखेंगे कि browser के अंदर:
Elements
Console
Network
Sources
Application
Storage
Performance
जैसी चीजों का use करके website और frontend को practically debug कैसे किया जाता है।