Open In App

Hypertext Transfer Protocol - HTTP

Last Updated : 16 Oct, 2025
Comments
Improve
Suggest changes
9 Likes
Like
Report

HTTP (Hypertext Transfer Protocol) is a fundamental protocol of the Internet, enabling the transfer of data between a client and a server. It is the foundation of data communication for the World Wide Web. HTTP provides a standard between a web browser and a web server to establish communication. It is a set of rules for transferring data from one computer to another.

Screenshot-2023-05-29-102548
HTTP Connection

Note: Data such as text, images and other multimedia files are shared on the World Wide Web. Whenever a web user opens their web browser, the user indirectly uses HTTP. It is an application protocol that is used for distributed, collaborative, hypermedia information systems.

Features

  • Stateless: Each request is independent and the server doesn't retain previous interactions' information.
  • Text-Based: Messages are in plain text, making them readable and debuggable.
  • Client-Server Model: Follows a client-server architecture for requesting and serving resources.
  • Request-Response: Operates on a request-response cycle between clients and servers.
  • Request Methods: Supports various methods like GET, POST, PUT, DELETE for different actions on resources.

Note: It was renamed as Hyper-Text Transfer Protocol QUIC (HTTP/3) and developed by Google.

Methods of HTTP

  • GET: Used to retrieve data from a specified resource. It should have no side effects and is commonly used for fetching web pages, images, etc.
  • POST: Used to submit data to be processed by a specified resource. It is suitable for form submissions, file uploads and creating new resources.
  • PUT: Used to update or create a resource on the server. It replaces the entire resource with the data provided in the request body.
  • PATCH: Similar to PUT but used for partial modifications to a resource. It updates specific fields of a resource rather than replacing the entire resource.
  • DELETE: Used to remove a specified resource from the server.
  • HEAD: Similar to GET but retrieves only the response headers, useful for checking resource properties without transferring the full content.
  • OPTIONS: Used to retrieve the communication options available for a resource, including supported methods and headers.
  • TRACE: Used for debugging purposes to echo the received request back to the client, though it's rarely used due to security concerns.
  • CONNECT: Used to establish a tunnel to the server through an HTTP proxy, commonly used for SSL/TLS connections.

HTTP Request/Response:

HTTP is a request-response protocol, which means that for every request sent by a client (typically a web browser), the server responds with a corresponding response. The basic flow of an HTTP request-response cycle is as follows:

  • Client sends an HTTP request: The client (usually a web browser) initiates the process by sending an HTTP request to the server. This request includes a request method (GET, POST, PUT, DELETE, etc.), the target URI (Uniform Resource Identifier, e.g., a URL), headers and an optional request body.
  • Server processes the request: The server receives the request and processes it based on the requested method and resource. This may involve retrieving data from a database, executing server-side scripts or performing other operations.
  • Server sends an HTTP response: After processing the request, the server sends an HTTP response back to the client. The response includes a status code (e.g., 200 OK, 404 Not Found), response headers and an optional response body containing the requested data or content.
  • Client processes the response: The client receives the server's response and processes it accordingly. For example, if the response contains an HTML page, the browser will render and display it. If it's an image or other media file, the browser will display or handle it appropriately.
http_request
HTTP Request/Response

HTTP Request Circle

This table explains how HTTP requests work when you visit a webpage and what happens behind the scenes. Here’s a breakdown of the process:

Requested ResourceResource TypeServer Response
HTML PageHTMLServer sends HTML file
Style Sheet (CSS)CSSServer sends CSS file
Image (JPG)Image (JPG)Server sends JPG image
JavaScript CodeJavaScript (JS)Server sends JS file
Data (XML or JSON)DataServer sends XML/JSON data
  1. Requested Resource: This is the type of content you're asking the server to send you. For example, it could be an HTML page, a style sheet (CSS), an image or JavaScript code.
  2. Resource Type: This tells the server what kind of file or data you need. For example, an HTML page would be of type HTML, a style sheet is CSS, an image would be an image type (like JPG), JavaScript code is of type JS and data could be in formats like XML or JSON.
  3. Server Response: After receiving the request, the server sends back the correct file or data based on the request. For example, if you requested an HTML page, the server sends back the HTML file or if you requested an image, the server sends back the image file.

Examples for each request

  • HTML Page: If you want a webpage, the server sends back the HTML content.
  • CSS: For styling a webpage, the server sends the CSS file.
  • Image: If you ask for a picture (like a JPG), the server sends the image.
  • JavaScript: If you need functionality for the page, the server sends the JS code.
  • Data: If you're looking for specific data (like in XML or JSON format), the server sends that data back.

Note: The "HTTP Request Circle" is just showing how a web browser requests different kinds of resources from a server and the server responds by sending the corresponding files or data.

Overview of HTTP Request and Response Components

ConceptDescription
HTTP Request HeadersText information in key-value pairs sent with every HTTP request, conveying details such as client's browser, requested data and more.
HTTP Request BodyContains data being submitted to the web server, such as form inputs, authentication details or other payload data.
HTTP ResponseSent by the server in answer to an HTTP request, consisting of an HTTP status code, response headers and optional response body.
HTTP Status Codes3-digit codes indicating the outcome of an HTTP request, categorized into 1xx (Informational), 2xx (Success), 3xx (Redirection), 4xx (Client Error) and 5xx (Server Error) blocks.
HTTP Response HeadersProvide important information like data format, language and content type in the response, helping clients interpret the data correctly.
HTTP Response BodyContains the requested information sent by the server, such as HTML content for webpages, JSON data or other data based on the client's request.

History of HTTP

  • Tim Berners-Lee and his team at CERN are indeed credited with inventing the original HTTP protocol.
  • HTTP version 0.9 was the initial version introduced in 1991.
  • HTTP version 1.0 followed in 1996 with the introduction of RFC 1945.
  • HTTP version 1.1 was introduced in January 1997 with RFC 2068, later refined in RFC 2616 in June 1999.
  • HTTP version 2.0 was specified in RFC 7540 and published on May 14, 2015.
  • HTTP version 3.0, also known as HTTP/3, is based on the QUIC protocol and is designed to improve web performance.

Advantages

  • Platform independence: Works on any operating system
  • Compatibility: Compatible with various protocols and technologies
  • Efficiency: Optimized for performance
  • Security: Supports encryption for secure data transfer

Disadvantages

  • Lack of security: Vulnerable to attacks like man in the middle
  • Performance issues: Can be slow for large data transfers
  • Statelessness: Requires additional mechanisms for maintaining state

Article Tags :

Explore