The browser sends the request message to the server

Source: Internet
Author: User

Resources: The order in which browsers load and render HTML

Domain name: is to give IP an alias, the role of the domain is to facilitate human memory


1> Browser sends request message to server
Http:/www/baidu.com:80/login.aspx

When I enter a browser in such a URL address: The first step of the browser to do is based on the www/baidu.com domain name to find the DNS server, resolved to the corresponding IP address.

For example, parse into: http://202.108.22.5:80/login.aspx

After the browser resolves to the IP address, the second step is to make HTTP encapsulation of the specified URL, encapsulating the URL as an HTTP message
After the browser encapsulates the URL as an HTTP message, the third step is to send the HTTP request message to the server
(Note: How does the browser send the HTTP request message to the server?) Answer: The browser creates a socket object internally, transforms the HTTP request message into a byet[] byte, and then calls the Socket.sent () method to send the data to the server)


2> server responds to browser


On the server side:
First: The server gets the HTTP request message to the browser to send the fire
(Note: How does the server get the HTTP request message sent over to the browser?) Answer: The server also received the HTTP request message data sent by the browser via the Socket.receive () method.
The second step: the server docking the received HTTP request packet data processing:
How to deal with it? 1> parsing HTTP Request messages first
2> based on the parsed message, the server side to find the resources requested by the user (if the user requested a static resource, the server directly through the file operation read these resources and then the resource through the call server-side Socktet Send () method directly to the browser (client), if the browser ( Client) requests a Dynamic Web page, the Web server (IIS) calls the corresponding. NET freamework to execute the code in the corresponding Dynamic Web page, and then sends the generated HTML code after execution to the browser (client) by calling Socket.sent ().


3> Browser Parsing render server response message (HTML code)Client:
The browser receives the HTML code sent by the server via the Scocket.receive () method and renders the HTML code.
How does the browser parse the HTML code? Answer: The browser received the server sent over the HTML code, and then the browser will be the HTML code from the top to the next sentence of the parsing, encountered some tags, such as <div>,<a>,<span>,<p> and other tags, The browser invokes the rendering engine to render the labels and then displays the results to the page. If you encounter a semantic explanatory tag embedded file (Image,js script, CSS style) For example: when encountering The browser will first display a picture of the box (window), if the IMG tag is set width and height, It will immediately fixed the size of the box (window), if there is no width and height, it will show a small default size of the box (window), and then again through the socket to the server to send request messages, To request 123.png This picture, request to 123.png this picture, if the IMG did not set the width and height before, this time only re-render its height and width, if the IMG has been set before the height and width, then just put 123.png this picture to fill in the box.
When encountering <link href= "Stylesheet1.css" rel= "stylesheet"/>, the browser will send a request message to the server via the socket again to request this stylesheet1.css file
When with to <script src= "Jquery-1.11.2.js" ></script>, the browser will send a request message like the server to request this jquery-1.11.2.js file

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The browser sends the request message to the server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.