How HTTP works

Hypertext Transfer Protocol (HTTP) provides a network protocol standard that web browsers and servers use to communicate. You see HTTP every day because when you visit a website, the protocol is written right in the URL.

This protocol is similar to the file transfer protocol in that it is used by the client program to request files from the remote server. In the case of HTTP, usually a web browser requests HTML files from the web server, then displays in the browser with text, images, hyperlinks and related assets.

Because browsers by default communicate using HTTP, you can usually remove the protocol from the URL when typing in the browser's address bar.

To learn more, please refer to the article: What is HTTP?

How HTTP works

HTTP is an application layer protocol built on TCP, using a communication model between the client and the server. Client and HTTP server communicate via request and response messages. The three main types of HTTP notifications are GET, POST and HEAD.

  1. HTTP GET - The message sent to the server contains only one URL. No or more optional data parameters can be appended to the end of the URL. The server processes the optional data portion of the URL, if any, and returns the result (a web page or web page element) to the browser.
  2. HTTP POST - The message places any optional data parameters in the body of the request message, instead of appending them to the end of the URL.
  3. HTTP HEAD - Requests act the same as GET. Instead of replying with the full text of the URL, the server only sends header information (included in the HTML section).
How HTTP works Picture 1
How HTTP works

The browser starts communicating with the HTTP server by starting a TCP connection to the server. Web browsing sessions use server port 80 by default, although other ports such as 8080 are sometimes used instead.

After the session is established, you enable sending and receiving HTTP messages by visiting the website.

HTTP is a stateless system. This means that unlike other file transfer protocols such as FTP, the HTTP connection is canceled after the request is completed. Therefore, after the web browser sends the request and the server responds to the page, the connection will be closed.

Troubleshooting HTTP

Messages transmitted over HTTP failed for a number of reasons:

  1. User error
  2. Malfunction of web browser or web server
  3. Error creating site
  4. Temporary network problem

When these errors occur, the protocol that captures the cause of the error and reports the error code back to the browser is called the HTTP status line / code. The error begins with a certain number to indicate what kind of error it is.

For example, errors with error codes starting with 4 indicate that the request for the page could not be completed properly or the request contained incorrect syntax. For example, a 404 error means that the page cannot be found. Some sites even offer interesting custom 404 error pages.

5 ★ | 4 Vote

May be interested

  • What is HTTPPhoto of What is HTTP
    http is an application-level protocol for distribution, collaboration, multimedia information systems, which is the foundation for data communication for www (eg internet) since 1990. http is a common protocol and stateless that can be used for other purposes as well as the scaling of request methods, error codes and its header.
  • Parameters in HTTPPhoto of Parameters in HTTP
    this chapter lists some of the http protocol parameters and their syntax by which they are used in communication.
  • Message in HTTPPhoto of Message in HTTP
    http is built on the basis of the client-server structure model and stateless request / response protocol, which is governed by the exchange of messages (message) along a tcp / ip connection.
  • Request (HTTP) in HTTPPhoto of Request (HTTP) in HTTP
    a client sends an http request to a server in the form a request message that includes the following format.
  • Response (Response) in HTTPPhoto of Response (Response) in HTTP
    after receiving and interpreting a request message, a server sends a response signal with an http response message.
  • Method in HTTPPhoto of Method in HTTP
    the set of common methods for http / 1.1 is defined below and this set of settings can be expanded based on the requirements. these method names are case-sensitive and they must be used in uppercase.