HTTP
gocourse.in Maintenance

We'll be back soon

Our CDN (cdn.gocourse.in) is currently unreachable. Some images, JavaScript, or CSS files may not load properly.

Estimated downtime: ~30 minutes

HTTP

Sabareshwari

Introduction

Whenever you open a website, watch a YouTube video, shop online, read a blog, or search on Google, your web browser communicates with a web server behind the scenes. This communication happens using a protocol called Hypertext Transfer Protocol (HTTP).

HTTP is one of the most important protocols on the Internet. It defines how web browsers (clients) request information from web servers and how servers respond to those requests. Without HTTP, browsing websites would not be possible.

Today, billions of web pages, web applications, and online services rely on HTTP to exchange information quickly and efficiently. Whether you are accessing social media, online banking, cloud applications, or e-commerce websites, HTTP plays a vital role in delivering content to your device.

In this article, we will explore HTTP from the ground up, understand how it works, learn its architecture, study its features, and see real-world examples that make the concepts easy to understand.

What is HTTP?

HTTP (Hypertext Transfer Protocol) is an Application Layer protocol in the TCP/IP protocol suite that enables communication between a client (such as a web browser) and a web server.

It is the foundation of the World Wide Web (WWW) and is responsible for transferring web pages, images, videos, documents, and other web resources over the Internet.

HTTP follows a client-server architecture, where:
  • The client sends a request.
  • The server processes the request.
  • The server sends back a response.
This communication is known as the Request-Response Model.

Simple Definition

HTTP is a communication protocol that allows web browsers and web servers to exchange information over the Internet.

Understanding the Term "Hypertext"

Before understanding HTTP, let's first understand Hypertext.

Hypertext is text that contains hyperlinks (clickable links) connecting one document to another.

For example:

You are reading a blog about Computer Networks.

The article contains a link:

Learn more about TCP/IP

When you click that link, another webpage opens.

That clickable text is called hypertext.

HTTP was designed to transfer these hypertext documents across the Internet.

What is the World Wide Web (WWW)?

Many beginners confuse the Internet with the World Wide Web (WWW).

They are not the same.

Internet

The Internet is a massive global network connecting millions of computers and devices.

It provides the infrastructure for communication.

World Wide Web

The World Wide Web is a collection of websites and web pages that run on top of the Internet.

The Web uses HTTP to transfer web pages between browsers and servers.

Relationship


World Wide Web_ Relationship_.svg

The Internet provides connectivity, while HTTP enables communication between web browsers and web servers.

Why Do We Need HTTP?

Imagine there were no standard communication rules on the Internet.

Every browser would communicate differently with every server.

For example:
  • Google Chrome uses one language.
  • Mozilla Firefox uses another language.
  • Microsoft Edge uses another format.
Servers would need to understand every browser individually.

This would create chaos.

HTTP solves this problem by providing a standard communication protocol that every browser and server understands.

Real-Life Analogy

Imagine you visit a restaurant.

The process looks like this:

Customer → Waiter → Kitchen → Waiter → Customer

Similarly, in HTTP:

Browser → HTTP Request → Web Server → HTTP Response → Browser

The waiter acts as the communication bridge between the customer and the kitchen, just as HTTP enables communication between browsers and web servers.

History of HTTP

HTTP was invented by Tim Berners-Lee while working at CERN to support the newly created World Wide Web.

Since then, HTTP has evolved significantly to improve speed, efficiency, and security.

HTTP/0.9 (1991)

The first version of HTTP was extremely simple.

Features:
  • Supported only the GET method.
  • Could retrieve only HTML documents.
  • No headers.
  • No status codes.
  • Very limited functionality.
Example:

GET /index.html

HTTP/1.0 (1996)

HTTP/1.0 introduced several important improvements:
  • HTTP headers
  • Status codes
  • Multiple content types
  • Better request handling
Each request created a new TCP connection.

HTTP/1.1 (1997)

HTTP/1.1 became the most widely used version for many years.

New features included:
  • Persistent (Keep-Alive) connections
  • Host header support
  • Better caching
  • Chunked data transfer
  • Improved performance
Most websites used HTTP/1.1 for nearly two decades.

HTTP/2 (2015)

HTTP/2 was designed to improve website performance.

Major improvements:
  • Multiplexing
  • Header compression
  • Server Push
  • Faster page loading
  • Better bandwidth utilization

HTTP/3 (2022)

HTTP/3 is the latest major version.

Instead of using TCP, it uses QUIC, which runs over UDP.

Benefits include:
  • Faster connection establishment
  • Reduced latency
  • Better performance on unstable networks
  • Built-in encryption using TLS 1.3

HTTP Architecture

HTTP follows the Client-Server Architecture.

Components

  • Client
  • Internet
  • Web Server
  • HTTP Protocol

Diagram


HTTP Architecture.svg


Components of HTTP Communication

1. Client

The client is the device or application that requests information.

Examples:
  • Google Chrome
  • Mozilla Firefox
  • Microsoft Edge
  • Safari
  • Mobile Apps
Responsibilities:
  • Sends HTTP requests.
  • Displays web pages.
  • Processes server responses.

2. Web Server

A web server stores website files and processes client requests.

Examples of web servers:
  • Apache HTTP Server
  • Nginx
  • Microsoft IIS
  • Lite Speed
Responsibilities:
  • Receives HTTP requests.
  • Processes requests.
  • Sends HTTP responses.
  • Stores website content.

3. Internet

The Internet acts as the communication medium connecting clients and servers worldwide.

Data travels through:
  • Routers
  • Switches
  • Optical Fiber
  • Wireless Networks
  • Internet Service Providers (ISPs)

4. HTTP Protocol

HTTP defines the rules that both the client and the server must follow while exchanging data.

It specifies:
  • Request format
  • Response format
  • Headers
  • Methods
  • Status codes

How HTTP Works

HTTP communication follows a simple Request-Response cycle.

Step 1

The user enters a URL.

Example:
https://www.example.com

Step 2

The browser finds the server's IP address using DNS.

Step 3

The browser establishes a connection with the server.

Step 4

The browser sends an HTTP request.

Example:
GET / HTTP/1.1
Host: www.example.com

Step 5

The server processes the request.

Step 6

The server returns an HTTP response.

Example:
HTTP/1.1 200 OK

<html>
...
</html>

Step 7

The browser displays the webpage.

HTTP Request-Response Flow


HTTP Request-Response Flow.svg


Example of HTTP Communication

Suppose you type:

https://www.wikipedia.org

The browser sends a request asking for the homepage.

The server receives the request, locates the required HTML file, and sends it back to the browser.

The browser then downloads additional resources such as:
  • Images
  • CSS files
  • JavaScript files
  • Fonts
Each of these resources requires its own HTTP request and response.

Features of HTTP

HTTP provides several features that make it suitable for web communication.

1. Client-Server Architecture

HTTP separates the client from the server.

This separation allows independent development and maintenance of web applications.

2. Connectionless Protocol

HTTP is traditionally considered a connectionless protocol.

The client sends a request, the server processes it, sends the response, and the communication for that request is complete.

Although modern versions like HTTP/1.1 support persistent connections, HTTP still follows the request-response communication model.

Example

Browser:

"Please send the homepage."

Server:

"Here is the homepage."

Connection completes after the response (or is reused if Keep-Alive is enabled).

3. Stateless Protocol

One of the most important characteristics of HTTP is that it is stateless.

A stateless protocol does not remember previous requests.

Every request is treated as completely independent.

Example

Suppose you visit:

example.com/login

After logging in:

example.com/profile

HTTP alone does not remember that you already logged in.

Without additional mechanisms, the server treats every request as coming from a new user.

This is why websites use cookies, sessions, and authentication tokens to maintain user state.

4. Media Independent

HTTP can transfer many different types of data.

Examples include:
  • HTML documents
  • Images
  • Videos
  • Audio files
  • PDFs
  • JSON
  • XML
The content type is specified using the MIME (Multipurpose Internet Mail Extensions) type in the HTTP headers.

5. Extensible

HTTP allows new headers, methods, and features to be added without changing the entire protocol, making it flexible and adaptable to modern web applications.

Cookies in HTTP

Since HTTP is stateless, websites need a way to remember users across multiple requests.

This is achieved using HTTP Cookies.

A cookie is a small piece of data stored in the user's browser by a web server.

The browser automatically sends the cookie back to the server with future requests to the same website.

Why Are Cookies Needed?

Cookies help websites:
  • Remember logged-in users
  • Store user preferences
  • Maintain shopping carts
  • Track user sessions
  • Personalize content
Without cookies, users would have to log in again every time they visited a new page.

Example

Imagine you log in to an online shopping website.

After successful login, the server sends a cookie to your browser.

When you visit another page, your browser automatically includes that cookie in the request.

The server recognizes you as the same user and keeps you logged in.

Real-Life Analogy

Think of a movie theater.

When you buy a ticket, you receive a wristband.

You don't need to show your ticket every time you enter a different hall.

The wristband identifies you.

Similarly, an HTTP cookie acts as an identification token that allows the server to recognize returning users.

Key Points to Remember

  • HTTP stands for Hypertext Transfer Protocol.
  • It is an Application Layer protocol.
  • HTTP powers the World Wide Web.
  • It follows the Client-Server model.
  • Communication occurs using the Request-Response mechanism.
  • HTTP is stateless.
  • Cookies help maintain user sessions.
  • HTTP can transfer various types of content, including HTML, images, videos, JSON, and PDFs.

 
Our website uses cookies to enhance your experience. Learn More
Accept !