Preliminary Analysis of HTTP protocol

Source: Internet
Author: User

Preliminary Analysis of HTTP protocol

1. What is HTTP?

HTTP is short for hypertext transfer protocol (hypertext transfer protocol). It is an application layer protocol of TCP/IP protocol. It defines how a Web client requests Web pages from a Web server, and the way the server sends web pages to the client.

Glossary in definition:
What is hyper text? Hyper Text uses hyperlinks to organize text information in different spaces. What is an application layer protocol? Network designers use a layered approach to organize network protocols and the hardware and software that implement these Protocols. In history, an important Protocol organization model is a five-layer Internet protocol stack, from the top layer to the bottom layer, they are the application layer, transport layer, network layer, link layer, and physical layer. Common protocols at the application layer include HTTP, SMTP, FTP, TCP, UDP, and IP at the network layer. Ii. HTTP protocol features 1. HTTP uses TCP as its transport layer protocol, and TCP provides reliable data transmission services for HTTP. With a layered structure, the HTTP protocol does not have to worry about data loss or pay attention to the details of TCP recovery from network data loss and out-of-order faults. 2. HTTP is a stateless protocol. The server sends the requested file to the client without saving any information about the client. (To save the file, use cookies ). 3. HTTP/1.0 uses a non-persistent connection, and HTTP/1.1 uses a persistent connection. Using persistent connections, you do not need to allocate TCP buffers and keep TCP variables multiple times in the client and server, and avoid twice the RTT delivery latency of each transmission object. HTTP uses a persistent connection with pipelines by default. Iii. HTTP message format 1. example of request message: GET/somedir/page.html HTTP/1.1 Host: www. someschool. eduConnection: closeUser-agent: Mozilla/5.0Accept-language: fr ------------------------------------------------------- First line: request lineOther lines: header line request line: Method Field-URL field-HTTP Version field, where, the GET, POST, HEAD, PUT, DELETE, and other methods can be used as the GET request by default. parameters are attached to the URL and the size is limited, the header method is usually used for debugging and only returns HTTP packets, but does not return the request object Co Nnection: close indicates that the common request headers of persistent connection are not used: Accept: text/html, and image/* acceptable data type Accept-Charset: the ISO-8859-1 accepts data using the character set Encoding Accept-Encoding: gzip, compress Accept the data compression format Accept-Language: en-us, zh-cn Accept the Language environment Host: www.it315.org: 80 virtual host name If-Modified-Since: Tue, 11 Jul 2000 18:23:51 GMT last get time of cache resource Referer: http://www.it315.org/index.jsp current request from which link User-Agent: mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0) client information Cookie Connection: close/Keep-Alive specifies whether to Keep the Connection Date: Tue, 11 Jul 2000 18:23:51 GMT current time 2. example of Response Message: HTTP/1.1 200 okConnection: closeDate: Tue, 09 Aug 2011 15:44:04 GMTServer: Apache/2.2.3 (CentOS) Last-Modified: Tue, 09 Aug 2011 15:11:03 GMTContent-Length: 6821Content-Type: text/html (Data, Data, Data ...) ------------------------------------------------------- First line: status lineLast line: entity bodyOthe R lines: header line status line: Protocol Version-status code-status information status code and status information common: 200 OK301 Moved Permanently400 Bad Request404 Not found505 HTTP Version Not Supported limit 100 ~ 199 indicates that the request is received successfully. The client must submit the request to complete the entire process ~ 299 indicates that the entire process is successfully received and completed. 300 ~ 399 to complete the request, the customer needs to further refine the request, such as 302 request redirection, 304,307 notification Using Cache 400 ~ 499 client request Error 500 ~ 599 Server errors common response header: Location: http://www.it315.org/index.jsp with 302 for request redirection Server: apache tomcat Server basic information Content-Encoding: the gzip server uses the compressed format Content-Length: 80 to send data. Content-Language: zh-cn: the Language in which data is sent. Content-Type: text/html; charset = GB2312 the basic information of the data currently sent Last-Modified: Tue, 11 Jul 2000 18:23:51 GMT cache-related Refresh: 1; url = http://www.it315.org regularly refreshes to a certain URLContent-Disposition: attachment?filename=aaa.zip download-related header Transfer-Encoding: chunked data transmission type, data Transfer block Set-Cookie: SS = Q0 = 5Lb_nQ; path =/search Set cookieETag: w/"83794-1208174400000" and Cache-related Expires:-1 specify the resource Cache time. If the value is 0 or-1, the resource Cache-Control is not cached: if no-cache is set to no-cache, the browser will be notified not to cache Pragma: no-cache. If no-cache is set to no-cache, the browser will be notified not to cache for historical reasons. All three of the above are used to control the cache, use Connection: close/Keep-Alive to Keep the Connection Date: Tue, 11 Jul 2000 18:23:51 GMT current time at the same time. 3. Telnet to demonstrate telnet cis.poly.edu 80 this article permanently updates the link address:

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.