HTTP Headers的Request Headers

Accept
-Encoding in the Accept HTTP Header is sent by the browser to the server to declare the MIME type supported by the browser

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp, / ;q=0.8. Meaning: the MIME types supported by the browser are text/html, application/xhtml+xml, application/xml and */*, and the priority is their order from left to right.

The English full name of MIME is Multipurpose Internet Mail Extensions (Multipurpose Internet Mail Extensions), which is a multipurpose Internet mail extension protocol. It was first applied to e-mail systems in 1992, but it was also applied to browsers later.

text/html, application/xhtml+xml, application/xml are all MIME types, which can also be called media type and content type. The type before the slash is type, and the one after the slash is subtype; type Specify a large range, subtype is the more specific type in type, that is, a small class in a large class.

Text: text information used for standardized representation. Text messages can be in multiple character sets and or multiple formats;

text/html means html document;

Application: used to transmit application data or binary data;

application/xhtml+xml means xhtml document;

application/xml means xml document;

*/* means any type.

Accept-Encoding in the Accept-Encoding
HTTP Header is sent by the browser to the server to declare the encoding type supported by the browser.
Common ones are

Accept-Encoding: compress, gzip //support compress and gzip types
Accept-Encoding: //default is identity
Accept-Encoding: * //support all types Accept-Encoding: compress;q=0.5, gzip;q=1.0// Support gzip, compress
Accept-Encoding: gzip;q=1.0, identity; q=0.5, *;q=0 // support gzip, identity in order

The corresponding type encoding header returned by the server is content-encoding. The server's rules for processing accept-encoding are as follows

  1. If the server can return any of the Encoding types defined in Accept-Encoding, the processing is successful (unless the value of q is equal to 0, which means it is not acceptable)
  2. "*" represents any Encoding type (except for the type defined in Accept-Encoding)
  3. If there are multiple Encoding matches at the same time, arrange them in order of q value
  4. Identity is always the accepted encoding type (unless the type is displayed as q=0).
    If the value of Accept-Encoding is empty, then only identity is the accepted type.
    If all types of servers in Accept-Encoding are not available Send back, then it should return 406 error to the client.
    If there is no Accept-Encoding in the request, then the server will assume that all Encodings are acceptable.
    If there is identity in Accept-Encoding, then identity should be returned first (unless there is a definition of q value, or you think another type is more meaningful)

Note:
If the server does not support identity and the browser does not send Accept-Encoding, then the server should tend to use the "gzip" and "compress" in HTTP1.0, and the server may send more suitable encoding types according to the client type. Most HTTP1 .0 clients cannot handle the q value.

Accept-Language
Accept-Language represents the language type supported by the browser;

zh-cn means simplified Chinese; zh means Chinese; "*" means wildcard;

q is the weight coefficient, the range is 0 =< q <= 1. The larger the value of q, the more inclined the request is to obtain the content represented by the type before the ";". If the value of q is not specified, the default is 1, if it is assigned 0, it is used to remind the server which content types are not accepted by the browser.

Referer
  When a browser sends a request to a web server, it usually brings a Referer to tell the server which page the web page is linked from, so the server can obtain some information for processing.

Guess you like

Origin blog.csdn.net/qq_41411324/article/details/111255215