Skip to main content

What is HTTP?

HTTP (HyperText Transfer Protocol) is an application-layer protocol that defines how a client and a server exchange data over the internet.

In simple terms: HTTP is the language browsers (or applications) and servers use to talk to each other.


Why HTTP is needed

HTTP is needed so that:

  • a client can request data (a page, a file, API data)
  • a server can understand the request
  • a server can return a result to the client

Without HTTP, a browser would not know:

  • how to properly ask for a page
  • how the server should respond
  • how to tell whether there was an error

How HTTP works (very simply)

HTTP works on this scheme:

request → response

  1. The client (browser, application) sends an HTTP request
  2. The server receives the request
  3. The server processes it
  4. The server sends an HTTP response
  5. The client uses the data it received

What can be transferred over HTTP

HTTP can transfer:

  • HTML pages
  • JSON and XML (API)
  • images
  • files
  • form data

HTTP does not care what is inside the data: it just describes the rules of transfer.


Key properties of HTTP

1. Application layer

HTTP works at the application layer of the OSI model and uses the lower layers (TCP/IP) to deliver data.


2. Stateless

HTTP is a stateless protocol:

  • the server does not remember previous requests
  • each request is processed independently
  • all the needed information is passed in the request

3. The client is always the initiator

  • the client always sends the request first
  • the server only responds

A server never sends HTTP data on its own.


Real-life example

When you type a site's address:

  • the browser sends an HTTP request: "Give me this page"
  • the server responds with an HTTP response: "Here is the page, status: success"
  • the browser displays the page

Short answer for an interview

Remember this handy wording:

HTTP is an application-layer protocol that defines the rules for exchanging data between a client and a server over the internet and is used to transfer web pages and API requests.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.