What is the HTTP Protocol?
HTTP, short for Hyper-Text Transfer Protocol, is an application layer protocol used for exchanging resources between a client and a server.

What are the Features of HTTP?
- Extensible through Headers: You can add headers, such as authorization, to requests.
- Stateless but Not Sessionless: HTTP is stateless, meaning consecutive requests are independent. However, it supports session management using cookies, allowing you to maintain session data for each client or user.
Media Type Independent: HTTP does not depend on the type of data being sent or received. The data type is specified through headers and chosen from MIME Types.
What are HTTP Messages?
HTTP messages are human-readable and come in two types: Request and Response. The resources involved have types called MIME Types, which define the content of the response.
What Constitutes a Request?
URL
Indicates the location of the resource.
Method
Known as HTTP verbs, including POST, PUT, GET, PATCH, and DELETE. These describe the action for the endpoint, such as adding (POST), updating (PUT), removing (DELETE), or retrieving resources (GET).
Headers
Optional attributes for the request.
Body
Contains the request content for methods like POST and PUT.
Version
The HTTP version being used, such as 3.0, 2.0, or 1.1.
What Constitutes a Response?
Version
The HTTP version used.
Headers
Attributes specific to the response, distinct from request headers.
Body
The content of the response, different from the request body.
Status Code
Identifies whether the request was successful or failed and why.
What are Status Codes?
Status codes provide additional information about the success or failure of a request and are divided into four categories:
1xx (Informational)
Example: 101, 102.
2xx (Success)
Example: 200 OK, 204 Accepted.
3xx (Redirectional)
Indicates the API has been redirected to another URL.
4xx (Client Error)
Indicates an error from the client’s side, such as Forbidden or Bad Request.
– 400 Bad Request
– 403 Forbidden
5xx (Server Error)
Indicates a server-side error. Example:
– 500 Internal Server Error
What are MIME Types?
Status codes provide additional information about the success or failure of a request and are divided into four categories:
MIME Types define the content of a message received from a response. Some common types include:
- text/html: Represents HTML content, either a full page or part of an HTML page.
- application/pdf: Represents a PDF file.
- application/xml: Represents an XML file.
application/json: Represents JSON data.
What is the HTTP Flow?
1. Open a TCP Connection: TCP is a Transport Layer protocol used for sending and receiving requests and responses. Multiple TCP connections can be opened simultaneously, or an existing connection can be reused.
2. Send HTTP Message: This is the request.
3. Receive and Read Response: The response is received and read.
4. Close or Reuse TCP Connection: The TCP connection is either closed or reused for further communication.