Working of HTTP
Working of HTTP
Every time you open your browsers, type some URLs and press enter, you will see beautiful web pages appear on your screen. But do you know what is happening behind these simple actions?
Normally, your browser is a client. After you type a URL, it takes the host part of the URL and sends it to a Domain Name Server (DNS) in order to get the IP address of the host. Then it connects to the IP address and asks to setup a TCP connection. The browser sends HTTP requests through the connection. The server handles them and replies with HTTP responses containing the content that make up the web page. Finally, the browser renders the body of the web page and disconnects from the server.
A web server, also known as an HTTP server, uses the HTTP protocol to communicate with clients. All web browsers can be considered clients. We can divide the web's working principles into the following steps;
- Client uses TCP/IP protocol to connect to server.
- Client sends HTTP request packages to server.
- Server returns HTTP response packages to client. If the requested resources include dynamic scripts, server calls script engine first.
- Client disconnects from server, starts rendering HTML.
This is a simple work flow of HTTP affairs -notice that the server closes its connections after it sends data to the clients, then waits for the next request.
A web browser is a computer application that reads files. When entering a URL (ex. https://www.sitesbay.com) into the address bar in a browser, the browser requests information in the form of a file associated with that specific URL. Your browser renders code in the form of a website.
When you want to see a website like sitesbay.com. You types the URL of a page using a client program, usually a browser. But first, the computer of the user and the web server need to be physically connected. That is the job of the internet. Using the TCP/IP protocol, it establishes a connection using a combination of cable media or wireless media and does all the necessary work to prepare the environment for the two computers to talk via the HTTP protocol.
When the connection establishes, the client sends a request called the HTTP message, but because the HTTP is a connectionless protocol, so the client disconnects from the server and waits for the response.
On the other side, the server processes the request, prepare the response, establish the connection again, and send it back the response and again in the form of an HTTP message to the client. Then the two computers completely disconnect.
Clients: are often browsers (Chrome, Edge, Safari), but they can be any type of program or device.
Servers: are most often computers in the cloud.
HTTP Request / Response
Communication between clients and servers is done by requests and responses;