Introduction to HTTP protocol

Source: Internet
Author: User
The Internet is connected by various protocols, and the most widely used protocol is HTTP, that is, Hypertext Transfer protocol, which is different from ftp, HTTP is simpler because it is mainly used for Hypertext Transfer. Today we will introduce the basic format of the HTTP protocol.
Here, the HTTP protocol we talk about is based on HTTP/1.1 and netvampirepro4.0 is used to obtain the communication log with the HTTP server, you can also use other HTTP download tools to obtain the communication log.
In the HTTP protocol, the server refers to the part that provides the HTTP service, and the client refers to the browser or download tool you use. During communication, the client sends a request to connect and the server establishes a connection. Then, the client sends an HTTP request, and the server returns the response information (respond) to complete an HTTP operation. Let's use an example to understand this process: (The following is a connection between netvampire and the red font added to the author)
P01-5-2616: 10: 43connectingtogow.3.com .. // connect to the server
P01-5-2616: 10: 44connectedtogoapps3.com [61.129.65.148] // resolution IP address, the following is an HTTP operation
S01-5-2616: 10: 44get /~ Minift/epretty/pretty.zip HTTP/1.1 // request line (requestline), indicating that files are obtained using get and HTTP/1.1 protocol
// The following is the request header (requesthead)
S01-5-2616: 10: 44 connection: Close // indicates a non-persistent connection
S01-5-2616: 10: 44 HOST: gow.3.com // host name
S01-5-2616: 10: 44 accept: */* // accepted data type
S01-5-2616: 10: 44 Pragma: No-Cache // parameters (compatible with previous servers)
S01-5-2616: 10: 44cache-control: No-Cache // do not use Cache
S01-5-2616: 10: 44 Referer: http://go2.163.com /~ Minift/epretty // transfer from this URL
S01-5-2616: 10: 44user-agent: Mozilla/4.04 [En] (Win95; I; NAV) // Client ID
S01-5-2616: 10: 44 COOKIE: ADid = acddaaaaaaa
S01-5-2616: 10: 44 // respond below
R01-5-2616: 10: 47 HTTP/1.0200ok // response line (respondline), server uses HTTP/1.0 protocol, status value (statuscode) is 200, status is OK, indicates the file can be read
R01-5-2616: 10: 47 Date: sat, 26may200108: 15: 54gmt // present time, expressed by Greenwich Mean Time
R01-5-2616: 10: 47 server: Apache/1.3.14 (UNIX) mod_layout/2.9.9 // server type
R01-5-2616: 10: 47last-modified: Fri, 04may200102: 42: 56gmt // last file update time
R01-5-2616: 10: 47 etag: "e614cf-37965-3af21730"
R01-5-2616: 10: 47accept-ranges: bytes // units of acceptable range
R01-5-2616: 10: 47content-length: 227685 // file length
R01-5-2616: 10: 47content-type: Application/zip // MIME type
R01-5-2616: 10: 47x-cache: missfromshca8
R01-5-2616: 10: 47x-cache-lookup: missfromshca8: 80
R01-5-2616: 10: 47 connection: Close // indicates that the connection is closed after the file is transferred.
R01-5-2616: 10: 47 // file transfer below
P01-5-2616: 10: 47 datatransferstarted
The following describes the format used (lrcf = @ 13 @ 10, that is, press enter, SP = space, that is, space)
Request:
Protocol SP file urisp Protocol version lrcf (request line)
(The following is the header)
Header type: Header Value lrcf
Header type: Header Value lrcf
Header type: Header Value lrcf
......
Lrcf indicates the end of The Header
(If there is a department, the following is the Department)

Respond:
Protocol version SP status value sp status description lrcf (Response line)
(The following is the header)
Header type: Header Value lrcf
Header type: Header Value lrcf
Header type: Header Value lrcf
......
Lrcf indicates the end of The Header
(If there is a department, the following is the Department)

It can be seen from the above that the request is only partially different from the corresponding format, which is easy to understand. Now you should have a basic understanding of the HTTP protocol and understand the communication logs, next we will talk about the meaning of the status value in the response line and some special cases.
In a protocol, the most important thing is to determine whether the protocol is successful. In HTTP, it is determined based on the response status value. Today we will introduce the meaning of some status codes.
200ok
This is the most common, that is, the Protocol is normal.CodeIndicates that all operations are successful.

404 notfound
This is also the most common. In fact, most errors are that the required resources cannot be obtained, which usually indicates that the file does not exist.

403 Forbidden
This indicates that the server cannot meet the current request. It may be due to a large number of connections.

401 unauthorized
For Unauthenticated requests, the browser usually receives the status value and a dialog box is displayed asking you to enter the password.

500 internalservererror
Internal Server error. The general cause is thatProgramIf an error occurs, a correct response cannot be returned.

206 partialcontent
Part of the content. This status code indicates that part of the content is passed below, which is also the standard return code for resumable data transfer.

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.