All pages
Powered by GitBook
1 of 1

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:


⚙️ How HTTP Works (Basic Flow):

  1. User enters URL in browser — e.g., http://example.com.

  2. Browser sends HTTP Request to the web server.

  3. Server processes the request and sends an HTTP Response back (e.g., an HTML page).

  4. 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:

Method
Purpose

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:

Code
Meaning
Description

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?

Feature
HTTP
HTTPS (Secure HTTP)

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:

Version
Description

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:

Feature
HTTP

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.