How does HTTP work?

HTTP, the Hypertext Transfer Protocol, is the application layer protocol that is used to transfer hypermedia on the Web. HTTP is the foundation of data communication for the World Wide Web. Hypertext is a structured text that uses logical links between nodes containing text. HTTP is the protocol to exchange or transfer hypertext. Development of HTTP was initiated by Tim Berners-Lee at CERN in 1989.

The first definition of HTTP/1.1, the version of HTTP in common use, occurred in RFC 2068 in 1997, although this was made obsolete by RFC 2616 in 1999 and then again by the RFC 7230 family of RFCs in 2014.

When you browse the web and want to read a document, which is somewhere else in the world and probably very far from you, some connections are needed to make it available. In this process, the very first thing is your browser. You start it up and type the URL into it.

However, the picture is still not complete, as the browser can't read the document directly from the disk where it's stored. To read the document, must run it on a web server. A web server is just a computer program that hears the requests from browsers and then executes them.

So what happens next is that the browser contacts the server and requests that server deliver the document. The server then gives a response which contains the document, and the browser happily displays the content to the user. The server also tells the browser, what kind of document it sending (Like HTML, PDF, TXT etc.) and the browser shows the document with the program it was configured to use for.

The browser will display HTML documents directly, and if there are references to images, Videos, sound clips etc. then the browser has been set up to display by requesting them from the servers. These will be separate requests and add additional load on the server and network. When the user follows another link the whole sequence starts again.

HTTP

These requests and responses are issued in HTTP. HTTP only defines what the browser and web server say to each other, not how they communicate. The actual work of moving bits and bytes back and forth across the network is done by TCP and IP.

A Web browser initiates a request to a server, typically by opening a TCP/IP connection. The request itself comprises -

  • a request line,

  • a set of request headers,

  • and an entity

Then the server sends a response that comprises -

  • a status line,

  • a set of response headers,

  • and an entity

The entity in the request or response can be thought of simply as the payload, which may be binary data. The other items are readable ASCII characters. When the response has been completed, either the browser or the server may terminate the TCP/IP connection, or the browser can send another request.

HTTPS (Secure HTTP)

HTTPS denotes the use of HTTP with SSL (Secure Socket Layer) protocol or its successor protocol Transport Layer Security (TLS), a transport-layer protocol.

Either of these protocols, which use encryption, can be used to create a secure connection between two machines. The browser uses SSL or TLS when connecting to a secure part of a website indicated by an HTTPS URL, that is, a URL with the prefix https://. The browser then uses HTTP to send and receive requests over this secure connection.

Recommended for you