HTTP
✅ What is HTTP?
HTTP (HyperText Transfer Protocol) is the foundation of data communication on the World Wide Web (WWW). It is a protocol used for transferring hypertext (web pages, images, videos, and files) between a web client (browser) and a web server.
When you visit a website (e.g., http://example.com
), your browser uses HTTP to communicate with the web server and load the website content.
🔑 Key Characteristics of HTTP:
Protocol Type
Application Layer Protocol (OSI Layer 7)
Connection Type
Stateless (each request is independent)
Port Used
Default Port 80
Data Format
Text-based (human-readable format)
Transport Protocol
Uses TCP (Transmission Control Protocol) for communication
URL Scheme
http://
⚙️ How HTTP Works (Basic Flow):
User enters URL in browser — e.g.,
http://example.com
.Browser sends HTTP Request to the web server.
Server processes the request and sends an HTTP Response back (e.g., an HTML page).
Browser displays content to the user.
🔁 HTTP Request & Response Structure:
✅ HTTP Request (From Client to Server)
Example of a GET request:
Method:
GET
,POST
,PUT
,DELETE
, etc.URL/Path:
/index.html
(what resource to access).HTTP Version:
HTTP/1.1
,HTTP/2
, etc.Headers: Extra information (browser, types of data accepted).
✅ HTTP Response (From Server to Client)
Example of a response:
Status Line:
HTTP/1.1 200 OK
(200 means success).Headers: Content-Type, Content-Length, Cookies, etc.
Body: The actual data (HTML page, image, file, etc.).
📊 Common HTTP Methods:
GET
Retrieve data from server (e.g., webpage).
POST
Send data to server (e.g., form submission).
PUT
Update/replace data on server.
DELETE
Delete resource on server.
HEAD
Retrieve headers only (no body).
OPTIONS
List available methods for resource.
📡 Common HTTP Status Codes:
200
OK
Request succeeded.
301
Moved Permanently
Resource has a new permanent URL.
302
Found
Resource temporarily moved.
400
Bad Request
Malformed syntax or invalid request.
401
Unauthorized
Authentication required.
403
Forbidden
Access denied.
404
Not Found
Resource not found.
500
Internal Server Error
Server encountered an error.
503
Service Unavailable
Server temporarily unavailable.
🔐 What about HTTPS?
Port
80
443
Encryption
❌ No encryption (data is plain text)
✅ Encrypted via SSL/TLS
Security
Vulnerable to eavesdropping
Protected from man-in-the-middle attacks
URL Prefix
http://
https://
💡 HTTPS is highly recommended for all websites today to ensure security and privacy.
🔄 Versions of HTTP:
HTTP/1.0
First major version, simple, no persistent connection.
HTTP/1.1
Persistent connections (keep-alive), chunked transfer.
HTTP/2
Binary protocol, faster multiplexing, header compression.
HTTP/3 (QUIC)
Uses UDP, improved speed, reliability, and security.
📋 Summary Table:
Full Form
HyperText Transfer Protocol
Layer
Application Layer
Port
80
Secure Version
HTTPS (Port 443, encrypted)
Common Methods
GET, POST, PUT, DELETE
Status Codes
200, 404, 500, etc.
Data Type
Text-based (HTML, JSON, XML, etc.)
Stateless?
Yes
Transport Protocol
TCP
🚀 Example in Real Life:
When you open
http://example.com
, your browser sends an HTTP GET request to the web server.The server sends back an HTTP 200 OK response with the webpage content.
Your browser renders and shows the page.
Last updated