The content displayed on your browser is a classic ice-burg scenario.
What happens beneath is a complex set of events in the web world.
Would you like to have a 30,000 feet/ high level understanding of what goes on in the background? or
Even as a programmer, do you still have questions like:
Http, html, browser, server, web application, language – how do all of these work together? or
How does a web server process a web request?
Lets try and understand.
Communication between your system (laptop/mobile/ipad etc) and other systems (servers or other user systems) on the internet are tightly linked together. The message transmission follows multiple layers and protocols. It is not easy to wrap one’s head around every aspect of these layers. You could read more about the 7 OSI layers (Application, Presentation, Session, Transport, Network, DataLink, Physical Layer) and dig deeper if your are interested. A study into all these layers comprises different fields in Computer Engineering.
At a high and broad level, to understand how our request travels to the server and comes back to the response, keep reading below:
What is – Http stands for Hyper-Text Transfer Protocol.
A protocol is a standard, hence Http merely defines a standard for the messages being transferred between a client and server. The http message has a defined format and follows a sequence of steps during the transfer between client and server.
A client is a web browser from which a user raises a web request seeking for some information and the request is sent to a web server that hosts a web application. The job of a web server is to process the request and return it back as a response to the client. Ever wondered – How does a web browser know where the request is coming from and to what to send back? It’s all explained below:
Almost all web traffic for http is sent over Port 80.
Two commonly used methods for a request-response between a client and server are: GET and POST.
- GET – Requests data from a specified resource
- POST – Submits data to be processed to a specified resource
Http Status Codes:
Also, when a browser requests for a page from a web server, http provides status codes to if an error to receive the response occurs.
The list of Http status codes and their meaning is available here.
One of the most common Http error message is:
|404 Not Found||The requested page could not be found but may be available again in the future|
Every Http request message will give you information about:
Http version used, url, Http Header, Http method and more
Similarly, the Http response object gives you information about:
Http version used, url, Http Header, Http method, Http Status code, Content and more
Many a times , it gets very confusing to relate all these terms and technologies together. Many software programmers learn to code in a particular language but often forget how a client and the server communicate. What is rendered on one’s browser is only the output of a series of steps that happen in the web world.
You may have questions like:
Http, html, browser, server, web application, language – how do all of them work together? or
How does a web server process a web request?
Let me explain this from a 30,000 feet view and not enlist small detail that may bog you down.
Here it is:
- A user/browser requests a web page
- Browser parses url to find the protocol used, port no., host and path. (Lets assume user makes a http web request)
- Browser does a DNS lookup to find the IP no. of the web server
- Browser then sends the Http request to the web-server
- This is the Http request object
- The web server now has access to the Http Request object
- Every web server has defined mappings, i.e. based on the extension, it will forward the request to the associated program/plugin.
- The web-server inspects the request and then forwards the Http request to the corresponding plugin that can handle the request. The software plugin/software engine thus gets full access to Http objects and methods.
- The request is then sent to the directory or the web application residing on the web server.
- As a web application programmer, you will have access to Http header, url and the http request object.
- (The web server can also maintain a session by using cookies.)
- The web logic may request for data from the database and send it as a response.
- The business logic in the web application processes the request and prepares a response object i.e. Http Response
- The web server then parses the response into Html
- Since most common browsers can only render Html, every web response is transmitted to the browser as html. The browser then renders the html on user interface as human readable content.
- A browser creates a DOM tree out of the Html it receives and renders it onto the screen.
- A point to remember is that different browsers have different ways to parse or execute JS, style-sheets, pdfs and other content.