1. HTTP (Hypertext Transfer Protocol)

  1. HTTP Headers

  1. Content-Encoding
    1. Writing requests (clients)
    2. Reading requests (servers)
    3. Writing responses (servers)
    4. Reading responses (clients)
    5. Overview table
    6. Syntax
      1. Example

Content-Encoding

The Content-Encoding header lists any codings used to encode the document into the message body. A content encoding is typically preserved end-to-end, and metadata headers (e.g. Content-Length) describe this encoded message.

Codings are listed innermost to outermost. Content-Encoding is the last transformation to be decoded before the document is parsed according to its media type semantics, after Transfer-Coding and Content-Length.

Writing requests (clients)

Clients may find it desirable to compress an request message body. Clients should send Expect: 100-continue so the server can verify it's able to read the listed coding.

If the server is not able to read the selected content coding, it will respond with 415 Unsupported Media Type; re-try the request according to the directions for handling that status code.

Reading requests (servers)

If the server does not understand any of the listed codings, return 415 (Unsupported Media Type) and describe the acceptable coding types in a response. Use an HTML or plain text document to describe the error; there is currently no standard, machine-readable way to list acceptable coding types for clients.

Writing responses (servers)

If the client specified a list of acceptable content-encodings in the Accept-Encoding request header, then select one of them, apply it to the response body, and list it in Content-Encoding.

Reading responses (clients)

If the client does not understand any of the listed codings, re-try the request with an Accept-Encoding header. Requests without an Accept-Encoding header can be sent with the server's choice of coding.

Overview table

Name
Content-Encoding
Description
Lists the transformations applied to the message body.
Direction
Both
Negotiated by
Accept-Encoding
Specification
RFC 7230: HTTP/1.1 Caching ยง6.1. Content-Encoding

Syntax

Content-Encoding = 1#content-coding

Content-Encoding options are case-insensitive. For clarity, connection options are written in lowercase, and header names are typically written in their typical title case.

Example

Content-Encoding: gzip