A Brief Explanation of The HTTP Protocol
- Sarthak Gupta
- Sep 26, 2021
- 2 min read
Whenever we type a URL in our browser's search bar, we see the prefix 'http://'. What exactly does this HTTP mean?
HTTP is a command and response based protocol that a 'client' and a 'server' use to interact. A 'client' is a program which can send a request to a server on the internet. A client can be a browser like Chrome/Safari or text-based programs like cURL or Telnet. A 'server' is a machine which returns a response to the client, which is usually in the format of an .html page.

When we type a URL into the search bar of a browser, it sends a GET request to the server on which the requested website is hosted. The browser locates the server using the unique IP (Internet Protocol) address of the server. IP addresses usually contain numbers separated by period marks, such as 17.72.224.47. However, humans use english-based conversions of the IP addresses known as URLs (Uniform Resource Locators). A URL is converted to the IP address by a program called a 'DNS Resolver'.
Requests and Responses
HTTP uses the request and response format for interaction between the client and the server. These requests and responses have a specific format which is followed by both the client program and the server.
The format of a request message includes a start line followed by optional headers and body content separated by a CRLF(Carriage Return and Line Feed). The start line of the request message details the request method, the URI (Uniform Resource Identifier) and the HTTP version which is to be used.

The request method defines the action which the server must perform. Some request methods are GET (retrieve a web page), POST (Upload data, File Uploads), PUT (Adds or Replaces Data) or DELETE (Deletes data from the database).
The HTTP responses follow a similar format with the start line (having a status code), optional headers and body content. The status code gives a numerical representation of the outcome of the response. A successful response will return a 200 status code and an unsuccessful returns a 400 status code.

Comments