HTTP header details

Source: Internet
Author: User

The HTTP header contains a series of important information.

For example, Status Code, response type, file encoding...

In alphabetical order

FirstThe HTTP header isAccept

 

AcceptOnly appears in the request

It indicates the acceptable media types on the browser.

For example, accept: text/html indicates that the browser can accept the server's reply type as text/html, which is also known as the HTML document.

If the server cannot return text/HTML data, the server should return a 406 error (non acceptable)

 

Wildcard * represents any type

For example, accept: */* indicates that the browser can process all types of data. (generally, this is what the browser sends to the server)

For example, accept: text/* indicates that all text subclasses are acceptable.

 

Accept supports multiple types separated by commas (,).

For example, accept: Audio/*; q = 0.2. The general idea of audio/basic is that the browser prefers the media type of audio/basic. However, if this type is not available, other audio types can also be used.

Here a q = 0.2 is displayed, which indicates the degree of Association. The default value is one, which is arranged in ascending order.

For example, accept: text/plain; q = 0.5, text/html, text/X-DVI; q = 0.8, text/X-C

The acceptable type priority is as follows:

1) text/HTML text/X-C

2) text/X-DVI

3) text/plain

 

Q is a value between 0 and 1. The default value of Q is 1. q = 0 indicates unacceptable (non acceptable)

 

Http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html (English)

SecondThe HTTP header isAccept-charset

Accept-charsetRepresents the character set supported by the browser

 

For example:Accept-charset: ISO-8859-1, UTF-8; q = 0.7, *; q = 0.3

This browser prefers the following character sets

1) favorite ISO-8859-1

2) then UTF-8

3) The last is * (all strings are not limited)

 

The corresponding response HTTP header field is Content-Type

 

If the character set requested by the browser is not responded by the server, the server should return error 406.

Note that this is only a flag, and the server mustProgramEnsure that the declared character set type is consistent with the character set used in the HTTP body.

For example, declare accept-charset: UTF-8 in the HTTP Header

However, the body uses gb2312 encoding... the browser is garbled --#

ThirdThe HTTP header isAccept-Encoding

Accept-EncodingIt is the encoding type that the browser sends to the server and declares that the browser supports

Common

 

 
Accept-encoding: compress, Gzip// Supports compress and Gzip
 
Accept-encoding:// The default value is identity. 
Accept-encoding :*// Supports all types
 
Accept-encoding: compress; q = 0.5, Gzip; q = 1.0// Supports gzip and compress in sequence
 
Accept-encoding: gzip; q = 1.0, identity; q = 0.5, *; q = 0// Supports gzip and identity in sequence
 
The corresponding type encoding header returned by the server is content-encoding.
 
The rules for the server to process accept-encoding are as follows:
 
1. If the server can return any type of encoding defined in accept-encoding, the processing is successful (unless the value of Q is equal to 0 and 0 is unacceptable)
 
2. * represents any encoding type (except for displaying the defined type in accept-encoding)
 
3. If multiple encoding matches at the same time, the values are sorted by Q.
4. Identity is always an acceptable encoding type (unless the displayed q = 0). If the value of accept-encoding is null, only identity is the accepted type.
 
If no type of server in accept-encoding is returned, the 406 error should be returned to the client.
 
If the request does not contain accept-encoding, the server assumes that all encoding is acceptable,
 
If accept-encoding has an identity, the identity should be returned first (unless the Q value is defined, or you think another type is more meaningful)
 
Note:
 
If the server does not support identity and the browser does not send accept-encoding, the server should tend to use "gzip" and "compress" in http1.0. The server may send more suitable encoding types according to the client type.
 
Most http1.0 clients cannot process the Q value.
 
Note:: HereQActually, it indicates the priority.

FourthThe HTTP header isAccept-Language

Accept-LanguageIndicates the language and region supported by the browser.

He also supports multiple options and Q

 

For example, accept-language: En-US, en; q = 0.8

Select en-us first, then en

Note: En-us is the standard American English representation. En stands for the English language. US stands for the United States region.

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.