[NET Learning Note (2)] Web Apps

Source: Internet
Author: User

For different Web page objects (including pictures, videos, scripts, reference links, etc.), we need to address them, which is determined by the URL: Uniform Resource Locator . When we look for a webpage, we enter the Web address, the first part is the hostname, and the next part is the path name. The type of pathname is rich, except that we can think of. jpg and other actual object suffixes, if we look at the Web page address, we will find that when the user is operating, the page will follow a variety of path names.


HTTP, the Hypertext Transfer Protocol, is the Protocol that Web applications follow.

One of our common structures is the C/s structure, which is the request and response between the user and the server.

The transmission of the object is mainly through the TCP protocol, the general port is 80, the first browser sent to create a connection request, and create a socket (two programs through a two-way communication connection to achieve data exchange, one end becomes a socket), the other end of the server received a TCP connection, told the browser it received, This is the browser sends the HTTP request, including the Url,http server receives the request, parses the response message, sends the request object to the browser, the browser begins parsing the received HTML, and, if necessary, may send the request again. Finally, the TCP connection is closed.

This transmission is stateless, that is, the server does not maintain any past requests.


TCP connections can also be divided into persistent and non-persistent connections, which allow multiple object transfers (http1.1), which allows only one object transfer (http1.0).

The difference between the two connections is mainly reflected in the server and browser Exchange data, if only one object can be transmitted at a time, then there will be frequent exchanges between the two, the efficiency is greatly reduced. (RTT increases, and overhead resources are required for each connection)

We will send the small packet from the client to the server and return the time called a RTT (round trip time), in the above connection process, the total time is 2 RTT and file transfer times, where the first RTT is the time to establish TCP, The second RTT is the time that the HTTP response message is sent.

The persistent connection is divided into two kinds of non-flowing water and flowing water, the former sends the request after receiving the previous response, and the latter sends the request after encountering a reference object.

The HTTP message includes a response message and a request message. Where the request message is something we can read directly, in general, it has the following format:

Header filed, can include host address, agent, connection status, support language and so on.

Among them, the request method mainly has these:

1.POST: Fill in the form on the webpage (such as register login information), upload the input 2.URL method in the body of the message: GET, enter the information to upload via URL

HTTP currently has two versions, one is 1.0, it supports Get,post,head and the other is 1.1, in addition to Get,post and HEAD, it also supports put (upload files to the specified path) and delete (delete url specified file). (head is used for testing, it does not put the request object in the response message)


The other is a response message.

Its format includes the status bar and the header bar, as well as the data.

The status bar includes the currently used version: Http1.0 or http1.1, as well as the current state, which includes the following States:

OK

301 Move Permanently

Request

404 Not Found

505 HTTP Version not supported

......

The first is the state of success, and several others are errors.

The header bar includes connection status, generated response message time, server, last modified time, content length, content type, and so on.


We know that HTTP is stateless, but many times we want to save the state, such as when we remember the password, we hope that the next time we can not re-enter the password, this is the use of cookie technology.

Cookie technology is through session tracking, the data stored in the user's local terminal, the data is encrypted.

Its components include the response message, the header bar of the request message, and the cookie file.

When the user first visits the webpage, in the request message, detects that no cookie exists, creates a new cookie (Set-cookie: Unique number), Entrybody is stored in the server database, the request message automatically contains the cookie ID when connected again, You can then read the data to the user's local terminal.

However, by understanding the technology, it is easy to see that there is a certain security hazard to cookies.


[NET Learning Note (2)] Web Apps

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.