A Beginner’s Guide to HTTP & HTTPS
Tags: webdev, beginners, ssl, security
Published: 2023-02-08 08:54:30

Probably everyone, at least who are attached to the field of Web Development in some way, have definitely heard the two very famous terms, **HTTP** and **HTTPS**.

Today, we are going to take a look at the different aspects of these topics. But let’s first start our journey with the **Request-Response Cycle**.

## Request-Response Cycle:
The whole Ecosystem of Internet has its pivot in this well-known phenomenon of _Request-Response Cycle_.

Maybe a lot of new terms for a beginner, but once read thoroughly, it makes the life of a beginner Web Developer much easy.

Formally, it is defined as the **flow of information** between **_clients_**(Spread across the world) and the **_server_**(**centralised** in case of **Web2.0** but **decentralised** in case of **Web3.0**).

Let’s take an example to understand it more clearly.

Whenever we type any **URL** in the search bar and then press Enter Key, the typed URL is sent to **DNS Server** of your _ISP(**Internet Service Provider**)_ which then maps the URL to the corresponding IP Address. Once the **IP Address** is fetched, a **Request** to the Server is made for the necessary details and it sends us back the Data or Webpage as a **Response**.

In short, it is the whole phenomenon of _initiating_ a **Web Request** for getting the necessary **Response** from the Backend Server.

![Request-Response Cycle](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k24di0cczig9c04zqsil.jpg)

## Web Protocols:
_Web Protocols_ are basically the set of rules that governs features, some of which are listed below :

- Will the connection be kept alive after a certain action or a period of time?


- Whether the flow of data is Unidirectional or not?


- Whether the whole Data flow be realtime or not?

Some most commonly used Web Protocols are:
1. **HTTP**

1. **HTTPS**

1. **WS** (Used in Handling _Web Sockets_)

1. **SSH** (Used in connecting to a _Remote shell_)    


## HTTP and HTTPS:
As per **MDN Docs**,

> _**Hypertext Transfer Protocol (HTTP)** is a web protocol for transmitting hypermedia documents, such as HTML. It was designed for communication between **web browsers** and **web servers**, but it can also be used for other purposes. HTTP follows a classical **client-server model**, with a client opening a connection to make a request, then waiting until it receives a response._

HTTPS is basically an extension of HTTP that adds an extra layer of security by **encrypting** the data being transferred between a **web server** and a **browser**.

When a user connects to a website using HTTPS, their connection to the website is encrypted using **SSL(_Secure Sockets layer_)** or **TLS(_Transport layer Security_)**. This makes it much more difficult for hackers to intercept and steal **sensitive information** such as _login credentials_, _credit card information_, or _personal data_.



![HTTP and HTTPS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pijzrjrem2knsjdmcd9u.png)

## SSL:
**SSL (Secure Sockets Layer)** and its successor, **TLS (Transport Layer Security)**, are protocols for establishing _authenticated_ and encrypted links between networked computers.

In order to establish an SSL connection, a website must first obtain an **SSL Certificate** from a trusted _certificate authority_ (CA). This certificate is used to authenticate the identity of the website, and to prove that the website’s domain name belongs to the organization that requested the certificate.

Once a website has an SSL certificate, it can configure its web server to use **SSL** for all connections to the website. When a user connects to the website using HTTPS, their browser will verify the _SSL certificate_ and establish an **SSL connection**.


![SSL](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xqy8w56fxrn3kl32kqba.png)

## Location of HTTP/HTPPS in the Network Model:
As per the **_OSI Model of Networking_**, The _HTTP/HTTPS_ Protocols are both located in the **Application layer**.