Home > other >  The fifth chapter Web principle and application development
The fifth chapter Web principle and application development

Time:10-12

WWW is currently the world's most influential Internet network, from the application function, the WWW is an interactive graphical interface of Internet services, is a client/server application system based on HTTP, which belongs to the client/server paradigm of distributed computing applications, WWW core technologies include HTML and HTTP, HTTP information organization form of language is the WWW service,

2. The principle of the HTTP protocol
HTTP communication mechanism is in the process of a complete HTTP communication, between a Web browser and the Web server will complete the following seven steps:

(1) to establish a TCP connectionBefore work starts on the HTTP Web browser first to establish the connection with the Web server through the network, the connection is done through TCP, the agreement together with the IP protocol to build the Internet, known as the TCP/IP protocol family, so the Internet is referred to as TCP/IP network, HTTP is than TCP application layer protocol for the higher level, according to the rules, only low-level protocol set up before, to make more layer protocol connection, therefore, must first establish a TCP connection, generally TCP connection port number is 80
(2) the Web browser sends a request to a Web server command & lt; Request - line>
Once the TCP connection is established, the Web browser will send a request to a Web server command
For example: GET/sample/hello. JSP HTTP/1.1
(3) the Web browser sends a request header information & lt; Headers>
Browser sends the request after the command, but also in the form of header information to the Web server sends some other information, then the browser sends a blank line & lt; Blank line> To notify the server, it has ended the headers sent
(4) the Web server response
After sending the request the client to the server, the server will client echo reply, HTTP/1.1 200 OK, the first part of the response is the version number of the agreement and the response status code
(5) the Web server sends the response headers
As the client with the request to send information about itself, the server will be along with the response to the user on its own data and the requested documents,
(6) the Web server to send data to the browser
Web server to the browser sent after the header information, it will send a blank line to represent the headers sent to this end, then, it could lead to the content-type response header information described in the format to send the request of the actual data
(7) Web server closes the TCP connection
Usually, once the Web server to the browser sends the request data, it will close a TCP Connection, and then if the browser or server joined the line of code in the header information Connection: keep alive -
TCP connection will remain open after sending, so the browser can continue to send the request through the same connection, keep the connection saved the time needed for build a new connection for each request, also save network bandwidth,

In the HTTP request, the first line must be a request (request line), used to indicate the request type (GET/POST), to access the resources, using the HTTP version (HTTP1.1, etc.), followed by a first section (the header), used to indicate the additional information of the server to use, is an empty line after the first, after this you can add any other data [as main body (body)],

3. The Cookie mechanism
Cookie is put forward by the W3C organization, first by the Netscape A mechanism of community development, because HTTP is A stateless protocol, once data exchange, the client and the server connection will be closed, exchange data need to establish A new connection again, this means that the server is unable to track the session from the connection, the user A purchased an item in the shopping car, when to buy again the server has been unable to determine the purchasing behavior is to belong to the user session, A session or user B to track the session, must introduce A mechanism, A Cookie is such A mechanism, it can make up for the shortage of the HTTP protocol stateless,
Its working principle is similar to the client are awarded a pass, each one, no matter who visit all must carry their passport, so that the server can confirm client identity from the pass, the Cookie is actually a small piece of text information, the client request to the server, if the server need to record the user state, use the response to the client browser issue a Cookie, the client browser will keep the cookies, when the browser to request the site, the browser request url submitted to the server, along with the Cookie server check the Cookie, to identify the user state,

4. The Session mechanism
Session is the server using a record client state mechanism, use rise than simple some cookies, Session is another record customer state mechanism, cookies are stored in the client browser, the Session stored on the server,
  • Related