Java Reference
In-Depth Information
those types matches the formats the server can offer, anything can be passed back to the cli-
Language Negotiation
HTTP Content Negotiation also has a simple protocol for negotiating the desired human lan-
guage of the data sent back to the client. Clients use the Accept-Language header to specify
which human language they would like to receive. For example:
Accept-Language: en-us, es, fr
Here, the client is asking for a response in English, Spanish, or French. The Accept-Lan-
guage header uses a coded format. Two digits represent a language identified by the ISO-639
standard. [ 8 ] You can further specialize the code by following the two-character language code
with an ISO-3166 two-character country code. [ 9 ] In the previous example, en-us represents
US English.
The Accept-Language header also supports preference qualifiers:
Accept-Language: fr;q=1.0, es;q=1.0, en=0.1
Here, the client prefers French or Spanish, but would accept English as the default transla-
Clients and servers use the Content-Language header to specify the human language for
message body translation.
Encoding Negotiation
Clients can also negotiate the encoding of a message body. To save on network bandwidth,
encodings are generally used to compress messages before they are sent. The most common
algorithm for encoding is GZIP compression. Clients use the Accept-Encoding header to
specify which encodings they support. For example:
Accept-Encoding: gzip, deflate
Here, the client is saying that it wants its response either compressed using GZIP or uncom-
pressed ( deflate ).
The Accept-Encoding header also supports preference qualifiers:
Search WWH ::

Custom Search