The HTTP message includes the client's request message to the server and the server's response message to the client. These two types of messages consist of a starting line, one or more header fields, a blank line that is just the end of the head field, and an optional message body. The header fields of HTTP include the general header, the request header, the response header, and the four parts of the entity header. Each header field consists of a domain name, a colon (:), and a domain value of three parts.
1. HTTP request mode
GET |
Request a file from a Web server |
POST |
Send data to the Web server for processing by the Web server |
PUT |
Send data to the Web server and store it inside the Web server |
HEAD |
Checks if an object exists |
DELETE |
Delete a file from the Web server |
CONNECT |
Providing support for channels |
TRACE |
Trace the path to the server |
OPTIONS |
Querying the performance of a Web server |
Note: The usual is get and post
2. Host
The requested Web server domain name address
3, User-agent
Details of the browser type that the HTTP client is running. With this header information, the Web server can determine the type of browser for the HTTP request client.
4. Accept
Specify the types of content that clients can receive, and the order in which the content types are received by the customer
5, Accept-lanuage
Specifies the language that the HTTP client browser uses to display the return information preference
6, Accept-encoding
Specifies that the Web server that the client browser can support returns the content compression encoding type. Indicates that the server is allowed to compress the output before it is sent to the client to conserve bandwidth. The return compression format that the client browser can support is set here.
7, Accept-charset
The set of character encodings acceptable to the HTTP client browser
8, Content-type
Displays the content type submitted by this HTTP request. This property is typically only required for post submission
There are two types of encoding for the Content-type attribute value:
(1) "application/x-www-form-urlencoded": the type of encoding used when the form data is submitted to the server, the default value is "application/x-www-form-urlencoded". However, this encoding is inefficient when sending large amounts of text to the server, including text or binary data that contains non-ASCII characters.
(2) "Multipart/form-data": When the file is uploaded, the type of encoding used should be "Multipart/form-data", which can both send text data and support binary data upload.
You can use "application/x-www-form-urlencoded" when committing to form data, and when you commit a file, you need to use the "multipart/form-data" encoding type.
9, Keep-alive
Indicates whether a persistent connection is required. If the Web server side sees the value here as "keep-alive", or if the request uses an HTTP 1.1 (HTTP 1.1 defaults to persistent connection), it can take advantage of the persistent connection
10, Response part
Header |
explain |
Example |
Accept-ranges |
Indicates whether the server supports the specified range request and what kind of staging request |
Accept-ranges:bytes |
Age |
Estimated time (in seconds, non-negative) from the original server to the proxy cache |
Age:12 |
Allow |
A valid request behavior for a network resource is not allowed to return 405 |
Allow:get, HEAD |
Cache-control |
Tell if all caching mechanisms can be cached and which type |
Cache-control:no-cache |
Content-encoding |
The type of return content compression encoding supported by the Web server. |
Content-encoding:gzip |
Content-language |
The language of the response body |
Content-language:en,zh |
Content-length |
The length of the response body |
content-length:348 |
Content-location |
Alternate alternative address to request resource substitution |
Content-location:/index.htm |
Content-md5 |
Returns the MD5 checksum value of a resource |
content-md5:q2hly2sgsw50zwdyaxr5iq== |
Content-range |
The byte position of this section in the entire return body |
Content-range:bytes 21010-47021/47022 |
Content-type |
Returns the MIME type of the content |
content-type:text/html; Charset=utf-8 |
Date |
Time the original server message was issued |
Date:tue, 08:12:31 GMT |
ETag |
The current value of the entity label of the request variable |
ETag: "737060cd8c284d8af7ad3082f209582d" |
Expires |
Date and time when the response expires |
Expires:thu, 16:00:00 GMT |
Last-modified |
Requested last modified time for resource |
Last-modified:tue, 12:45:26 GMT |
Location |
Used to redirect the receiver to the location of the non-request URL to complete the request or identify the new resource |
Location:http://www.zcmhi.com/archives/94.html |
Pragma |
Includes implementing a specific instruction that can be applied to any receiver on the response chain |
Pragma:no-cache |
Proxy-authenticate |
It indicates the authentication scheme and the parameters on the URL that can be applied to the proxy |
Proxy-authenticate:basic |
Refresh |
Applied to redirect or a new resource was created, redirected after 5 seconds (proposed by Netscape, supported by most browsers) |
Refresh:5; Url=http://www.zcmhi.com/archives/94.html |
Retry-after |
Notifies the client to try again after a specified time if the entity is temporarily undesirable |
retry-after:120 |
Server |
Web Server Software Name |
server:apache/1.3.27 (Unix) (Red-hat/linux) |
Set-cookie |
Set HTTP Cookies |
Set-cookie:userid=johndoe; max-age=3600; Version=1 |
Trailer |
Indicates that the header domain is present at the end of the chunked transfer code |
Trailer:max-forwards |
Transfer-encoding |
File transfer encoding |
Transfer-encoding:chunked |
Vary |
Tells the downstream agent whether to use the cache response or request from the original server |
Vary: * |
Via |
Tells the proxy client where the response was sent by |
via:1.0 Fred, 1.1 nowhere.com (apache/1.1) |
Warning |
Warning about possible issues with the entity |
warning:199 Miscellaneous Warning |
Www-authenticate |
Indicates the authorization scheme that the client request entity should use |
Www-authenticate:basic |
HTTP request header information explained