๐ HTTP and HTTPS
We already learned that a browser sends a request to a server, and the server sends a response back.
But how do they communicate?
One of the most important answers is HTTP.
1๏ธโฃ What Is HTTP?
HTTP stands for:
HyperText Transfer Protocol
It is a set of rules that allows clients and servers to communicate over the web.
In simple words:
HTTP defines how a browser and server exchange information.
The basic flow is:
Browser
โ
HTTP Request
โ
Server
โ
HTTP Response
โ
Browser
2๏ธโฃ What Is an HTTP Request?
When your browser wants something from a server, it sends an HTTP request.
For example, you enter:
example.com
Your browser may send a request asking for the webpage.
A request contains information that helps the server understand what the browser wants.
3๏ธโฃ What Is an HTTP Response?
After receiving the request, the server sends an HTTP response.
The response can contain:
HTML
CSS
JavaScript
JSON
Images
Other information
So:
Request = "I want this resource."
Response = "Here is the resource/result."
4๏ธโฃ HTTP Methods
HTTP provides different methods for different types of actions.
The most common ones are:
GET
Used to retrieve data.
Example:
GET /products
Meaning:
Give me the products.
POST
Used to send/create data.
For example, creating a new account:
POST /users
PUT
Usually used to replace/update existing data.
PATCH
Used to partially update data.
DELETE
Used to delete data.
For example:
DELETE /users/25
Meaning:
Delete user 25.
You'll use these extensively when we learn REST APIs and backend development.
๐ Real-World Example
Imagine an online shopping application.
View products
GET /products
The server returns product information.
Create an order
POST /orders
The browser sends order information to the server.
Update an order
PATCH /orders/100
The browser asks the server to update part of the order.
Delete something
DELETE /cart/items/5
The browser asks the server to remove an item.
So HTTP methods help communicate the intended action.
5๏ธโฃ HTTP Status Codes
The server also sends a status code with its response.
You've probably encountered some of these.
200 โ OK
The request was successful.
201 โ Created
Something was successfully created.
400 โ Bad Request
The request contains something invalid or cannot be processed as sent.
401 โ Unauthorized
Authentication is required or the provided authentication is not valid.
403 โ Forbidden
The server understood the request but refuses to allow it.
404 โ Not Found
The requested resource couldn't be found.
500 โ Internal Server Error
Something went wrong on the server.
๐ง Easy Way to Remember Status Codes
2xx โ Success
3xx โ Redirection
4xx โ Client/request-related error
5xx โ Server error
You don't need to memorize every status code right now.
These are enough to start:
200, 201, 400, 401, 403, 404, 500
6๏ธโฃ What Is HTTPS?
HTTPS stands for:
HyperText Transfer Protocol Secure
HTTPS is HTTP with an encrypted connection using TLS (Transport Layer Security).
This helps protect data while it travels between your browser and the server.