Article directory
Explanation of HTTP request header information
HTTP messages include request messages from the client to the server and response messages from the server to the client. Both types of messages consist of a start line, one or more header fields, a blank line that just ends the header fields, and an optional message body. The HTTP header field includes four parts: general header, request header, response header and entity header.
Each header field consists of a domain name, a colon (:) and a field value.
1. HTTP request method
GET | Request a file from the web server |
---|---|
POST | Send data to the web server for the web server to process |
PUT | Send data to the web server and store inside the web server |
HEAD | Check if an object exists |
DELETE | Delete a file from the web server |
CONNECT | Provide support for channels |
TRACE | Trace the path to the server |
OPTIONS | Query the performance of the web server |
Note: GET and POST are commonly used
2、Host
The domain name address of the requested web server
3、User-Agent
Details of the type of browser the HTTP client is running. Through the header information, the web server can determine the browser type of the client of the http request.
4、Accept
Specifies the content types that the client can receive. The order of the content types indicates the order in which the clients receive them.
5、Accept-Lanuage
Specifies the preferred language for HTTP client browsers to display returned information
6、Accept-Encoding
Specifies the content compression encoding type returned by the web server that the client browser can support. Indicates that the server is allowed to compress the output before sending it to the client to save bandwidth. What is set here is the return compression format that the client browser can support.
7、Accept-Charset
The set of character encodings accepted by HTTP client browsers
8、Content-Type
Displays the content-type submitted by this HTTP request. Generally, this property only needs to be set when the post is submitted.
There are two encoding types for the Content-Type property value:
(1) "application/x-www-form-urlencoded": The encoding type used when the form data is submitted to the server, the default default value is "application/x-www-form-urlencoded". However, this encoding is inefficient when sending large amounts of text, text containing non-ASCII characters, or binary data to the server.
(2) "multipart/form-data": When uploading files, the encoding type used should be "multipart/form-data", which can send both text data and binary data upload.
When submitting as form data, you can use "application/x-www-form-urlencoded"; when submitting as a file, you need to use "multipart/form-data" encoding type.
9、Keep-Alive
Indicates whether a persistent connection is required. If the web server sees the value here as "Keep-Alive", or sees that the request is using HTTP 1.1 (HTTP 1.1 defaults to persistent connections), it can take advantage of persistent connections
10. Response section
Header | explain | Example |
---|---|---|
Accept-Ranges | Indicates whether the server supports the specified range request and what type of segment request | Accept-Ranges: bytes |
Age | Estimated time from origin server to proxy cache formation (in seconds, non-negative) | Age: 12 |
Allow | Valid request behavior for a network resource, if not allowed, return 405 | Allow: GET, HEAD |
Cache-Control | Tell all caching mechanisms if they can be cached and which type | Cache-Control: no-cache |
Content-Encoding | The returned content compression encoding type 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 | Requesting an alternate alternate address for the resource | Content-Location: /index.htm |
Content-MD5 | Returns the MD5 checksum of the resource | Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ== |
Content-Range | the byte position of this part 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 | The time the origin server message was sent | Date: Tue, 15 Nov 2010 08:12:31 GMT |
ETag | The current value of the entity tag of the request variable | ETag: “737060cd8c284d8af7ad3082f209582d” |
Expires | Date and time when the response expires | Expires: Thu, 01 Dec 2010 16:00:00 GMT |
Last-Modified | The last modification time of the requested resource | Last-Modified: Tue, 15 Nov 2010 12:45:26 GMT |
Location | Used to redirect the recipient to an unrequested URL to complete the request or identify a new resource | Location: http://www.zcmhi.com/archives/94.html |
Pragma | Includes implementation-specific directives that apply to any recipient in the response chain | Pragma: no-cache |
Proxy-Authenticate | It indicates the authentication scheme and parameters that can be applied to the proxy on this URL | Proxy-Authenticate: Basic |
refresh | Applied to redirects or a new resource is created, redirects after 5 seconds (proposed by Netscape, supported by most browsers) | Refresh: 5; url=http://www.zcmhi.com/archives/94.html |
Retry-After | If the entity is temporarily unavailable, notify the client to try again after the specified time | Retry-After: 120 |
Server | web server software name | Server: Apache/1.3.27 (Unix) (Red-Hat/Linux) |
Set-Cookie | Set HttpCookie | Set-Cookie: UserID=JohnDoe; Max-Age=3600; Version=1 |
Trailer | Indicates that the header field exists at the end of the chunked transfer encoding | Trailer: Max-Forwards |
Transfer-Encoding | file transfer encoding | Transfer-Encoding:chunked |
Vary | Tell downstream proxies whether to use cached responses or request from origin servers | Vary: * |
Via | Tell the proxy where the client response is sent | Via: 1.0 fred, 1.1 nowhere.com (Apache/1.1) |
Warning | Warn entities of possible problems | Warning: 199 Miscellaneous warning |
WWW-Authenticate | Indicates the authorization scheme that the client requesting entity should use | WWW-Authenticate: Basic |