What is an HTTP Request?

Nipuni Premadasa
Nerd For Tech
Published in
5 min readMay 14, 2023

--

Hi readers !!!👋

When we are talking about the internet, the importance of HTTP cannot be understated. Without HTTP we can’t even imagine web pages, URLs, hyperlinks, or anything related to the internet. Instead, users need to use low-level protocols such as TCP/IP to transfer data and need to know the exact IP address of the server host they want to access. HTTP (Hypertext Transfer Protocol) is the vital protocol used to facilitate the transfer of data between clients and servers over the Internet.

Understanding the fundamentals of HTTP requests is essential for comprehending how data flows on the web and how various internet services function together. In this blog, I will discuss what HTTP requests are, and explore their components, functionalities, and significance in modern web development.

If the Internet is a restaurant, HTTP is its waiter service. It ensures the transfer of information between client and server, like how waiters carry orders from customers to kitchen and foods from kitchen to customers.

In this context, HTTP acts as a command language through which clients and servers interact. For instance, when you enter a website address into your web browser, it initiates an HTTP request to the server, requesting the necessary resources. In this situation, your browser which is making the request is called the client. The URL you are requesting is the address that belongs to the server. The server processes this HTTP request, and generates an HTTP response containing the requested web page, ensuring a seamless browsing experience.

A correctly composed HTTP request consists of several components.

  1. Request line

The request line is the first line of the request message sent by the client to initiate the action on the server. It contains the following three elements.

Request line

a. Request method

The request method informs the server of the type of action the client desires. This is usually a verb (GET, POST) or a noun (HEAD) and is always written in uppercase. There are several types of HTTP request methods that have their own purpose.

· GET — Retrieve data from the server

· POST — Send information to the server

· PUT — Edit/update existing resources

· DELETE — Delete a resource on the server

· PATCH — Partially update existing resources

b. Path

The path is the URL for the request and it identifies the resource on the server.

c. Version of the protocol

The HTTP version number indicates the attempt made by the client to conform the message to the HTTP specification.

2. The request header

HTTP headers provide additional information about the message that is sent by the client to the server. Each HTTP header is represented by a name and a value. The following figure provides an example of an HTTP request header.

HTTP request header

These headers contain information that can be used to process the request or determine how the server should respond to the request. For example, Host indicates the hostname of the server that is trying to connect. The User-Agent provides information about the client and Accept-Language Specifies all languages ​​preferred by the client.

Apart from the headers in the above image, there can be headers such as authorization, cookies, referrer and etc.

3. The request body

The request body is the data included in an HTTP request that is transferred from the client to the server. This is the actual content of the message. This is an optional element because not all requests have a body. In some cases, such as when using the POST method, the request may include a body that contains data to be sent to the server. This is commonly used for submitting form data, JSON payloads, or file uploads. When the server receives the request, it will parse the request body and use it to create a new entry in the database.

After sending, the server processes this HTTP request and generates an HTTP response containing the requested resources, and sends it back to the client. It contains a status line, headers, and a message body.

HTTP response header

You can check this HTTP request header and response in Google Chrome by following the steps below.

1. Open Google Chrome and visit a URL.

2. Right-click and select inspect or press f12 to open developer tools.

3. Select the network tab.

4. Refresh the page.

5. Select any request in the left panel.

6. You can see the HTTP headers on the right panel.

Network tab in the developer tool

Conclusion

To conclude, HTTP (Hypertext Transfer Protocol) plays a crucial role in enabling seamless communication and data exchange between clients and servers on the Internet. By understanding how HTTP requests work, we gain insights into the foundation of web development and the mechanisms behind browsing experiences. From initiating requests to retrieving resources, HTTP serves as the backbone of our digital interactions, ensuring smooth information flow. As we continue to navigate the ever-expanding realm of the internet, let us appreciate the significance of HTTP in shaping our online experiences and driving the functionality of websites and applications we rely on every day.

We have reached the end of the article and I hope you got something useful from this article.😃 Thanks for reading❤️!

--

--

Nipuni Premadasa
Nerd For Tech

Undergraduate at Faculty of Information Technology, University of Moratuwa | Former Trainee Software Engineer at Embla Software Innovation(PVT) Ltd., Sri Lanka