1

I'm reading the HTTP spec, and I can't figure out exactly what "entities" are. I read the answer to "What exactly is an HTTP Entity", but I'm still confused.

Specifically, I don't understand the distinction the spec makes between entity-headers and response/request/general-headers. For example, reading the Header Field Definitions section, headers such as Allow, Expires, and Last-Modified are classified as "entity-headers." What does that actually mean? I guess they apply to an "entity-body", but what's the difference between an entity-body and a message-body?

I'd appreciate any clarification on entities and where they fit in a HTTP request/response.

Community
  • 1
  • 1
theabraham
  • 15,840
  • 9
  • 42
  • 41

2 Answers2

4

The message is the most generic term and refers to a whole HTTP message, including the start-line, message-header fields, and the message-body (may be empty).

The entity of a message is the payload that is to be transmitted. This can be identical to the message-body, but if there was a transfer encoding applied to the entity, the entity-body is obtained from the message-body by decoding any transfer encodings.

An example for such a transfer encoding is the chunked transfer coding where the entity body is transferred in chunks, e.g.:

HTTP/1.0 OK 200
Transfer-Encoding: chunked

9
This is a
C
 chunked mess
4
age.
0
‍

Here the message-body is:

9
This is a
C
 chunked mess
4
age.
0
‍

but the entity-body is the message-body with decoded chunked encoding:

This is a chunked message.
Community
  • 1
  • 1
Gumbo
  • 643,351
  • 109
  • 780
  • 844
  • I see, that makes more sense! So would the "message-header" contain all four header distinctions (entity, request, response, and generic headers?) And then would the answer to the previous question I posted be incorrect? He says everything except for the response/request line is part of the entity, even though the `Host` header isn't an "entity-header". – theabraham Dec 10 '12 at 23:29
  • 1
    @theabraham Again, *message-header* is the generic term. And any header is a *message-header*. For requests and responses, there are special [request header fields](http://tools.ietf.org/html/rfc2616#section-5.3) and [response header fields](http://tools.ietf.org/html/rfc2616#section-6.2). Header fields, that can be used in both requests and responses are [general header fields](http://tools.ietf.org/html/rfc2616#section-4.5). And header fields that specifically describe the entity are [entity header fields](http://tools.ietf.org/html/rfc2616#section-7.1). – Gumbo Dec 10 '12 at 23:41
  • Very cool, thank you. That's what I thought, but the previous answer to a similar question (which I saw you commented on) put everything as an entity. That led to some confusion. – theabraham Dec 10 '12 at 23:46
  • @theabraham And, yes, as I’ve already commented on the other answer, *Host* is not an [entity header field](http://tools.ietf.org/html/rfc2616#section-7.1) as it doesn’t describe the entity. It rather describes the destination the entity is to be sent to. – Gumbo Dec 10 '12 at 23:47
0

Case 1. You're uploading 3 files in a http request. Those 3 files are 3 entities. Each of them has its own Content-Type to indicate what kind of file it is.

Case 2. You're viewing a web page. Browser has downloaded a html file as the entity via a http response in the background. The file may be updated continuously. So the entity you got yesterday may be different from the one you get today.

Case 3. You've got a 304 Not Modified. No entity has been transmitted.

An entity is an optional payload inside a http request or response. Part of the headers are used to describe it.

Anderson
  • 2,496
  • 1
  • 27
  • 41