HTTP Communication

An Introduction to HTTP Protocol

Kubotor

--

HTTP — HyperText Transfer Protocol — is a stateless protocol, working on the application layer. It is the backbone of the internet. It basically works on the Client-Server model or Request-Response model. This protocol is the base on which the whole internet communication is working. It is known as the stateless protocol for the following reasons:

  • Every single transaction you make in HTTP is independent and is not related to any other transaction.
  • The current request does not know what has been done in the previous request
  • Still, a lot of web applications can track you via cookies and session tokens.

Components of HTTP-based systems

The following are the basic components of HTTP:

  1. Client
  2. Server
  3. Proxy

Client : User-Agent

User-Agent is a request header that allows a characteristic string that allows network protocol peers to identify the Operating System and Browser of the web-server. Your browser sends the user agent to every website you connect to. There is a general syntax of writing a user agent string, as shown in the below :

Syntax

User-Agent: <product> / <product-version> <comment>

Common format for web browsers:

User-Agent: Mozilla/5.0 (<system-information>) <platform> (<platform-details>) <extensions>

The browser sends an original request to fetch the HTML document that represents the page. It then parses this file, making additional requests corresponding to execution scripts, layout information to display, and sub-resources contained within the page. The Web browser then binds these resources to present to the user a complete document, the Web page. Scripts executed by the browser can fetch more resources and the browser updates the Web page accordingly.

Web Server

On the contrary to the communication channel, is the server, which serves the document which is requested by the client. A server appears as only a single machine virtually: this is because it may actually be a collection of servers. A server is not necessarily a single machine, but several server software instances can be hosted on the same machine.

Proxy

Between the communication of the Web browser and the server, numerous computers and machines relay the HTTP messages. Due to the layered structure of the Web stack, most of these operate at the transport, network or physical levels. Those operating at the application layers are generally called proxies. Proxies forward the requests they receive without altering them in any way. Proxies may perform numerous functions:

  • caching (the cache can be public or private, as the browser cache)
  • filtering (like an antivirus scan)
  • load balancing (to allow multiple servers to serve the different requests)
  • authentication (to control access to different resources)
  • logging (allowing the storage of historical information)

What HTTP Can Control

Here is a list of common features controllable with HTTP.

  • Caching
    How documents are cached can be controlled by HTTP. The server instructs proxies and clients, about what to cache and for how long.
  • Relaxing the origin constraint
    Web browsers enforce strict separation between Web sites, for preventing snooping and other privacy invasions.
  • Authentication
    Some pages are accessed by specific users. Basic authentication is provided by HTTP, either using the WWW-Authenticate and similar headers or by setting a specific session using HTTP cookies.
  • Proxy and tunneling
    Some
    Servers or clients are located on intranets and maintain their anonymity. HTTP requests go through proxies to cross this network barrier. Not all proxies are HTTP proxies.
  • Sessions
    HTTP cookies allow you to link requests with the server state. This creates sessions, despite basic HTTP being a stateless protocol. This is useful for e-commerce shopping baskets and for any site allowing user configuration of the output.

In our next post we will be learning about HTTP headers and methods.

References:

  1. https://developer.mozilla.org/en-US/docs/Web/HTTP
  2. https://www.youtube.com/watch?v=SzSXHv8RKdM&t=376s
  3. https://www.youtube.com/watch?v=k6fy7mvNSnY&t=32s
  4. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent

Credits

  1. Abhijeet Singh (abhijeet.s@kubotor.com)
  2. Devashish Kapoor (devkapoor000@gmail.com)

--

--