TCP/IP Note 4. Application Layer (3) -- HTTP

Source: Internet
Author: User

TCP/IP Note 4. Application Layer (3) -- HTTP 1. URLURL (Uniform Resource Locator) is equivalent to an extension of a file name in the network range. 1.1 format schema: // host [: port #]/path /.../[? Query-string] [# anchor] scheme specifies the IP address or domain name of the host http server (where resources are stored) for the Protocol (for example, HTTP, https, and ftp) used at the lower layer) port # The default port number of the HTTP server is 80. In this case, the port number can be omitted. Path: The path to access the resource. query-string: the data sent to the http server anchor-anch2. HTTPHTTP (HyperText Transfer Protocol), HyperText Transfer Protocol. HTTP is an application layer protocol that uses TCP connections for reliable transmission. 2.1 Working Process (1) the browser analyzes the URL of the hyperlink pointing to the page. (2) the browser requests DNS to resolve the IP address of www.tsinghua.edu.cn. (3) the Domain Name System DNS resolves the IP address of the Tsinghua University server. (4) Establish a TCP connection between the browser and the server (5) run the get file command: GET/chn/yxsz/index.htm. (6) The server returns a response and sends the file index.htm to the browser. (7) release the TCP connection. (8) The browser displays all the text in index.htm, the "Tsinghua University faculty Settings" file. Note: To open a webpage, you usually need to Request multiple times: (1) when the browser first obtains the index.html page, then the browser parses index.html (2) and finds that there is still a lot of information, such as other reference information such as slice, css, and js, then the browser will automatically send a Request for this information (3) when all the data is obtained, the browser will display the webpage. (Generally, the page is displayed after the general framework of the page is obtained.) 2.2 features (1) transaction-oriented Client Server protocol. (2) HTTP 1.0 is stateless (stateless ). The request of the same client does not correspond to the previous request. For the http server, it does not know that the two requests come from the same client. To solve this problem, the Web Program introduces the Cookie mechanism to maintain the status. (3) HTTP itself is also connectionless, although it uses connection-oriented TCP upstream services. (4) The World Wide Web browser is an HTTP client, and the process of waiting for HTTP requests on the World Wide Web server is often called HTTP daemon. Some documents abbreviated it as HTTPD. (5) After receiving a request from an HTTP client, HTTP daemon returns the required file to the HTTP client. 2.3 HTTP message format HTTP has two types of messages: Request (Request Message)-send a Request message from a customer to the server. Response Message: the answer from the server to the customer. 2.3.1 Request first looks at the structure of the Request message. The Request message consists of three parts: Request line, Request header, and body. there is an empty line between the header and the body. The structure is as follows: the Method in the first line indicates the request Method, such as "POST", "GET", and the URL indicates the requested resource, http/version-number indicates the HTTP protocol version number. When the "GET" method is used, the body is empty. Methods: The Http protocol defines many methods to interact with the server. There are four basic methods: GET, POST, PUT, and DELETE. a URL address is used to describe resources on a network. The GET, POST, PUT, and DELETE operations in HTTP correspond to four operations to query, modify, add, and DELETE resources. The most common ones are GET and POST. GET is generally used to obtain/query resource information, while POST is used to update resource information. The difference between GET and POST is: (1) the data submitted by GET will be placed after the URL,? Splits the URL and transmits data. parameters are connected with each other, for example, EditPosts. aspx? Name = test1 & id = 123456. the POST method places the submitted data in the Body of the HTTP package. (2) The size of the data submitted by GET is limited (because the browser has a limit on the URL length), and the data submitted by the POST method is not limited. (3) Request must be used for GET. queryString to get the value of the variable, while the POST method uses Request. form to obtain the value of the variable. (4) submitting data in GET mode brings security issues. For example, when submitting data in GET mode on a login page, the user name and password will appear on the URL, if the page can be cached or accessed by others, you can obtain the user's account and password from the history. 2.3.2 Response status code: 1xx indicates the notification information, if the request is received or is being processed. 2xx indicates that the request is successful, such as accepting or knowing. 3xx indicates redirection, indicating that further action must be taken to complete the request. 4xx indicates the customer's error. If the request contains an incorrect syntax or cannot be completed. 5xx indicates a server error. If the server fails, the request cannot be completed.

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.