Diving into the HTTP

Madushan perera
5 min readFeb 14, 2023

--

Understanding the Fundamentals and Benefits of the Hypertext Transfer Protocol and how it works

What is the HTTP?

HTTP is an abbreviation for Hypertext Transfer Protocol. It is a communication protocol used for data transmission on the World Wide Web (WWW). It is a client-server protocol, which means that a client (such as a web browser) requests resources or information from a server (such as a web server), and the server responds to the client.

client-server communication

Note: The HTTP (Hypertext Transfer Protocol) protocol primarily operates at the Application layer (layer 7) of the OSI (Open Systems Interconnection) model. However, it also makes use of lower-layer protocols such as TCP (Transmission Control Protocol) at the Transport layer (Layer 4) and IP (Internet Protocol) at the Network layer (Layer 3) for data transmission across the network

OSI model with protocols

HTTP is a connectionless protocol?

Yes, HTTP is a connectionless protocol because it works on a request-response basis, with each request and response treated as a separate transaction. This means that the server treats each request from the client as a separate connection, and the server does not maintain a continuous connection to the client.

Difference between Connection-oriented and Connection-less protocols

HTTP is a stateless protocol?

Yes, HTTP is a stateless protocol, which means it doesn’t keep track of previous requests or responses. Each client request to a server is treated as a separate transaction, and the server has no way of knowing if the current request is related to any previous requests.

How HTTP works?

Initially, the client sends an HTTP request to the server, specifying the type of action it wants to take, such as retrieving a web page and sending data to the server. The request includes information such as the URL of the requested resource, the HTTP method (such as GET or POST), and any additional data or headers required for the specific request.

Example of HTTP request

The server receives the HTTP request and processes it. If the requested resource exists on the server, it sends back an HTTP response.

The response includes a status code, which indicates the result of the request, such as success (200 OK) or failure (404 Not Found), and any data or resources requested by the client. The response may also include additional information, such as headers, that provide additional context or information about the response.

Example of HTTP response

The client receives the HTTP response and processes the data or resources returned by the server.

This cycle of request-response can occur multiple times between the client and server as they exchange information and resources.

HTTP Request: types of HTTP requests

There are several types of HTTP requests, each with a specific purpose and use case. The most commonly used types of HTTP requests are GET, POST, HEAD, PUT, DELETE, CONNECT, and OPTIONS. Understanding the different types of HTTP requests is essential for working with HTTP and building web applications.

GET: The most commonly used HTTP request method, GET requests to retrieve data from a server. GET requests are used to retrieve a web page, images, videos, and other resources from a server. They are typically used to retrieve information and are the most common type of HTTP request.

POST: POST requests send data to a server. They are used to submit forms, upload files, and send data to a server for processing. Unlike GET requests, POST requests are not cached or stored by the browser, and the data sent with a POST request is not visible in the URL.

HEAD: Head requests are similar to GET requests, but they only retrieve the headers of a response, not the actual resource. Header requests are useful for checking the status of a resource without downloading the entire resource.

PUT: PUT requests to update an existing resource on a server or create a new resource if it doesn’t exist. PUT requests are typically used to upload files or update resources on a server.

DELETE: DELETE requests to delete a resource on a server. They are used to remove resources or data that are no longer needed.

CONNECT: Connect requests are used to establish a secure connection to a server, typically for the purpose of establishing a secure connection to a proxy server.

OPTIONS: OPTIONS requests are used to retrieve information about the communication options available for a resource. They are typically used to retrieve information about the allowed methods and the communication options for a resource.

Basic Mind Map — HTTP protocol

Next>>> HTTP Cookies

In the next article, I will be discussing HTTP Cookies. Cookies are small text files stored on a user’s device by a website, and they are used to store information about a user’s preferences, login credentials, and browsing history. HTTP cookies play a crucial role in maintaining state and providing a personalized experience for users on the internet. They are also used for tracking and analytics purposes. In the next article, I will discuss how HTTP cookies work, the types of cookies, and the benefits and drawbacks of using cookies.

Read more about HTTP Cookies : https://medium.com/@madushan-perera/http-cookies-how-websites-track-our-online-activities-c89f7ee312d9

Follow me for more & Keep getting in touch with me!

--

--