官术网_书友最值得收藏!

User requesting a web page

When a user goes to the browser and types a URL, what exactly is happening?

  1. The browser tries to look up the IP address of the domain name in the URL by getting it from the DNS Server. Think of DNS as a directory mapping the domain name to the IP Address.

 

  1. Once the browser has the IP Address, it sends a HTTP request to that IP Address on port 80. If the URL is secure (HTTPS), then the request is sent to port 443. A simple HTTP request that is sent in plain text format looks like this: 
    GET /hello.html HTTP/1.1.
  2. The request also contains headers that are shared to pass additional information about the request, such as authentication information, cookies, or the type of the browser making the request.
  3. The request is routed through all of the routers to the final destination, which is an application or web server serving web pages.
  4. The server looks at the request and figures out what type of request it is. In our simple example, we made a GET request. The following types of request are supported by the web/application server: GET, POST, PUT, PATCH, DELETE, and HEAD
  5. The server also looks at the request and figures out what path is being requested. In our example, we are requesting a web page at the /hello.html path.
  6. In the request, we specify the protocol we are using, which is the HTTP/1.1 protocol. Currently HTTP/2 is also available and certain browsers that support it will make a request with it.
  7. The request can also contain headers that contain extra information from the browser for the server to figure out how to respond. After the header section, the request is followed by two empty new lines that tell the server that it has received the entire request message and now it is time for the server to respond.
  8. The server then will either generate the hello.html page or serve it from disk. The web servers that serve HTML pages from disk are called static web servers while the web servers that dynamically generate content are called application servers as they have some business logic to generate the HTML content dynamically based on the type and the user requesting it.
  9. The server replies back to the request with a response. The response format is similar to the request where the first few lines are called the response headers and they are key value pairs of metadata, followed by two new lines, and then followed by the HTML response or plain text response from the server.
  10. The server closes the connection, which tells the browser that it has received all of the response and then it renders the HTML or plain text in the browser.
主站蜘蛛池模板: 土默特左旗| 普安县| 深圳市| 宜兰市| 墨脱县| 安溪县| 浑源县| 布尔津县| 兰州市| 忻城县| 义乌市| 游戏| 县级市| 泰顺县| 南华县| 临泉县| 大洼县| 洪江市| 刚察县| 新余市| 开江县| 比如县| 兴化市| 武城县| 镇远县| 康乐县| 涞源县| 阜阳市| 新余市| 宁武县| 安溪县| 商南县| 峨山| 汉沽区| 桓仁| 潞城市| 合水县| 同仁县| 贺州市| 崇仁县| 行唐县|