HTTP protocol structure

xiaoxiao2021-03-06  38

1. Introduction HTTP (Hypertext Transfer Protocol), the Chinese name is a hypertext transfer protocol, working in the OSI seven-layer system, which belongs to the high-level application protocol. The HTTP protocol is mainly used to communicate between browsers and web servers. The HTTP protocol is transmitted using a clear text. If you need to transfer it, you can use HTTPS (Note: J2ME is temporarily not supported). 2, the HTTP protocol version of the HTTP protocol has 3 versions, which are 0.9, 1.0, 1.1.1. The latest version is 1.1, but 1.0 is generally supported. 3, the protocol format HTTP protocol is used in the use of clear text, the protocol is mainly divided into three parts: a) Request line / response line: This section only has a line: the request method requests the version of the HTTP protocol to use by the resource. For example: Get /Index.html http / 1.1 where GET is requesting method, / index.html is the resource requested, and HTTP / 1.1 refers to the version of the HTTP protocol supported by the client. There are three types of HTTP1.0 requests, and there are 7 kinds of HTTP1.1 request methods. HTTP method is commonly used with GET, Head, POST, and PUT, DELETE, LINK, UNLINK Method B) Head Information: Head Information Some of the main transmission server or some set information of the client, you can have any multiple, transfer time "name : Value "form, for example: accept-language: zh-cn user-agent: mozilla / 4.0 (compatible; msie 5.01; windows NT 5.0) where 40 head information names are specified in the HTTP protocol, you can also Need to define yourself. At the end of the header, a blank line and the entity data portion are required to be separated. C) Entity data: When the entity data is requested, if the parameters are stored in the POST mode, it is empty when requesting the GET. When the response is stored, the data of the HTML source code feedback is stored. 4, the HTTP connection process When communicating, the client is issued by the client, the server establishes the connection; then, the client is sent, and the server returns the response information (respond), thereby completing an HTTP operation.

5, example: P 01-5-26 16:10:43 Connecting to go2.163.com ... // Connecting server P 01-5-26 16:10:44 Connected to go2.163.com [61.129. 65.148] // Analyze the IP address, the following is the HTTP operation S 01-5-26 16:10:44 GET / ~MINIFT/EPRETTY/Pretty.zip http / 1.1 // Request line, indicating that using the GET method File, use the HTTP / 1.1 protocol // below to request the header (Request Head) S 01-5-26 16:10:44 Connection: Close / / means a non-sustained connection S 01-5-26 16:10:44 Host: Go2.163.com // Host Name S 01-5-26 16:10:44 Accept: * / * // Accepted Data Type S 01-5-26 16:10:44 Pragma: no-cache / / Parameters (compatible with previous servers) S 01-5-26 16:10:44 cache-control: no-cache // Do not use cache s 01-5-26 16:10:44 referer: http: // go2 .163.com / ~ minift / epretty // From this URL S 01-5-26 16:10:44 user-agent: mozilla / 4.04 [en] (Win95; NAV) // client identifier S 01-5-26 16:10:44 cookie: adid = ACDDAAAAAAAS 01-5-26 16:10:44 // The following is the response line ( Respond line, the server uses the HTTP / 1.0 protocol, status code is 200, the status is OK, indicating that the file can be read R 01-5-26 16:10:47 Date: Sat, 26 May 2001 08:15 : 54 GMT // Time now, using Greenwich Time to represent R 01-5-26 16:10:47 Server: Apache / 1.3.14 (UNIX) MOD_LAYOUT / 2.9.9 // Server Type R 01-5-26 16: 10:47 Last-Modified: Fri, 04 May 2001 02:42:56 GMT // Final Update Time R 01-5-26 16:10:47 ETAG: "E614CF-37965-3AF21730" R 01-5-26 16:10:47 ACCEPT-RANGES: BYTES // Accepted Range R 01-5-26 16:10:47 Content-Length: 227685 // File Length R 01-5-26 16:10:47 Content-Type : Application / Zip // MIME Type R 01-5-26 16:10:47 X-Cache: Miss from Shca8r 01-5-26 16:10:47 X-Cache-Lookup: Miss from SHCA8: 80R 01-5 -26 16:10:47 Connection: Close // Indicates that the file is transferred to close the connection.

转载请注明原文地址:https://www.9cbs.com/read-69404.html

New Post(0)