HTTP Entity

The Entity is transferred by the HTTP request and response message if not otherwise restricted by the request method or response status code. An entity is used to consist of entity-header fields and entity-body, although some responses will only include the entity-headers.

In this section, both the sender and recipient refer to either the client or the server, which depends on who receives the entity.

Entity Header Fields

Entity-header fields are used to define the metainformation about the entity-body. If body isnot present, the entity-header field defines metainformation about the resource identified by request. Some of this metainformation is OPTIONAL. Some might be REQUIRED by the portion of this specification.

Syntax

  1. entity-header = Allow                    
  2.         | Content-Encoding       
  3.         | Content-Language           
  4.         | Content-Length            
  5.         | Content-Location           
  6.         | Content-MD5                
  7.         | Content-Range              
  8.         | Content-Type               
  9.         | Expires                    
  10.         | Last-Modified              
  11.         | extension-header  
  12.     extension-header = message-header  

The extension-header mechanism is used to allow the additional entity-header fields, which is defined without the protocol change, but these fields cannot be assumed to be recognizable by the recipient. Recipient ignores the unrecognized header fields and MUST be forwarded by transparent proxies.

Entity Body

If there is any entity-body, it will send with an HTTP request or an HTTP response in the format as described below. The entity-header fields define the encoding.

Syntax

  1. entity-body    = *OCTET  

When a message-body is present, an entity-body will only present in a message. The entity-body is obtained from the message-body using decoding any Transfer-Encoding that might have been applied to ensure the proper and safe transfer of the message.

Type

When an entity-body is included with a message, the header fields Content-Type and Content-Encoding determines the data type of that body. These are used to define a two-layer, ordered encoding model:

Syntax

  1. entity-body := Content-Encoding( Content-Type( data ) )  

Content-Type is used to specify the media type of the underlying data. Content-Encoding indicates any additional content coding which is applied to the data, usually for the purpose of data compression that is a requested resource property.

Any message of HTTP/1.1 containing an entity-body SHOULD include a Content-Type header field that defines the media type of that body.If and only if a Content-Type field is not given the media type, the recipient MAY attempt to guess the media type using the inspection of its content or the name extension of the URI, which is used to identify the resource. The recipient SHOULD treat it as "application/octet-stream" type if the media type remains unknown.

Entity Length

The message of an entity length is the length of the message body before applying any transfer-coding.