Hypertext Transfer Protocol (HTTP) is an application layer protocol for data communication on the World Wide Web. It is a request-response type protocol for communication between clients and servers. This means that a client, usually a browser, sends an HTTP request to a server, often a computer in the cloud. The server receives the request, processes it and returns an HTTP response to the client.
HTTP defines methods to indicate what action the client wants to perform. For example, on the request side, GET requests information and POST requests that data is added (e.g., when submitting a username and password). HTTP also defines status codes on the response side. For example, HTTP status codes include 404 (page not found), 200 (OK – successful request) and 500 (internal server error). Since HTTP is an application layer protocol, it defines how requests and responses are communicated, but not how the data is transported. An underlying transport layer protocol is used for that.
HTTP itself is stateless, meaning that every request is individual and there are no connections between two requests. So when adding something to the basket on an e-commerce webpage and refreshing the page, the item would disappear since the server does not retain any information about the state or previous session. This problem has been solved with HTTP cookies–small pieces of data stored on the user’s computer, making websites remember stateful information.
Cookies are set using HTTP headers. HTTP headers are tiny pieces of custom information sent with the request or the response. They can be added to both sides and they can be either standardised fields or completely customised.