The essence of the browser's working principle is to implement the HTTP protocol communication, the process is as follows:
The process of HTTP communication is broadly divided into three phases:
Connection The server listens to port 8000 through a ServerSocket class object, hears the connection and opens a socket virtual file.
Request After creating the stream object associated with the socket connection, the browser obtains the request, and, for the GET request, obtains the access HTML file name from the request information and sends the request to the server.
Answer After the service receives the request, the search for the relevant directory file, if not present, returns an error message. If present, then want to HTML file, add HTTP Prime processing after the response to the browser, the browser parses the HTML file, if it also contains pictures, videos and other requests, the browser again access the Web server, the exception to get pictures and videos, and to assemble the display.
How browsers work