HTTP
Web browsers, apps, and servers use this protocol to exchange requests and responses. It defines how a client asks for data or an action and how the server reports the result.
What HTTP does
HTTP (Hypertext Transfer Protocol) is the application-layer protocol behind the web. When a browser loads a page, it usually requests the HTML first, then makes more requests for things the page needs, such as stylesheets and images. The same protocol lets a mobile app fetch account details or a backend service submit data to another service. Despite the name, HTTP can carry more than hypertext: JSON, images, and video are all common.
How a request becomes a response
A request identifies a target resource and uses a method to tell the server what to do. GET asks for a representation of the resource. POST asks the target resource to process the data sent with the request. Headers add information such as which response formats the client can accept. Depending on the method and endpoint, a request may also carry a body, such as a JSON object for a new order.
The server replies with a status code, headers, and, when appropriate, a body. A 200 OK response indicates success, 404 Not Found says the requested resource wasn't found, and 204 No Content indicates success without a response body. A Content-Type header tells the recipient how to interpret the data, so clients don't have to guess whether it's JSON, HTML, or something else.
Example: look up a catalog item
In this HTTP/1.1 request, Host identifies the site, /items/42 is the path, and Accept tells the server the client wants JSON:
GET /items/42 HTTP/1.1
Host: catalog.example
Accept: application/json
If the item exists, the server might respond:
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 22
{"id":42,"name":"Pen"}
The blank line separates the response headers from the body. Here Content-Length is the number of body bytes. In application code, you usually read parsed fields and return a response object rather than building this wire format yourself.
Common mix-ups
Stateless doesn't mean the app can't remember you. HTTP doesn't require the server to remember earlier requests. An app can still store a shopping cart on the server and use a session ID sent in a cookie to look it up. Reusing a connection isn't what identifies the session.
HTTPS doesn't change what a request means. It uses TLS to protect HTTP traffic in transit. HTTP versions can also differ in how they carry the same kinds of messages: HTTP/1.1 and HTTP/2 typically run over TCP, while HTTP/3 uses QUIC over UDP. A GET still has the same meaning across those versions.
What interviewers look for
Expect a retry scenario: a client creates an order, but the request times out before it gets a response. Did the server create the order? The client can't tell from the timeout alone. Retrying a plain POST might create a second order. A good answer explains how an API can use an idempotency key so the server recognizes a retry of the same logical operation.