I am trying to make better sense of HTTP internals, and often "entities" and "messages" are mentioned in the specification, strangely enough without proper explanation though, believe it or not. From what I gathered, one identifies the content itself, even when split across a request / response chain and/or transfer encoding fragmentation rules, while the other identifies content of a single HTTP request - i.e. what follows the headers and ends with a CRLF. My problem is I cannot figure out which one is which exactly.
+1
A:
A HTTP-message is either a request or a response:
HTTP-message = Request | Response ; HTTP/1.1 messages
A HTTP-message has zero or more message-headers and may have a message-body:
generic-message = start-line *(message-header CRLF) CRLF [ message-body ]
So not every HTTP-message has a message-body. But if it has a message-body, then that’s also the entity-body:
message-body = entity-body | <entity-body encoded as per Transfer-Encoding>
So in short: A message is the whole HTTP request or response. And the entity is the message’s body (if there is any) and its corresponding entity header fields.
Gumbo
2010-02-16 15:28:40
Ok, but what is an entity-body in the above? Let us consider a POST request with content type specified as "multipart/form-data" that carries file data, and a couple of variable-value pairs. In the request, a message is the entire request, header and all, right? The body of the message is the binary blob that follows the headers, right? The thing is, I think entity body is something else... Anyways, as you can see, I am almost as confused as I was...
amn
2010-02-16 15:35:13
@amn: The entity is in the message. The entity is the sum of *entity-header* s and the *entity-body* (the *message-body*). Some of the *message-header* s describe the message and some describe the entity. *Date*, for example, is a *message-header* (it describes the message) and *Content-Type* is a *entity-header* (it describes the entity).
Gumbo
2010-02-16 16:04:41
Yes, that explains it all, thanks! I figured that a message encodes and transfers an entity, while entity has a type - and so both are defined by different headers.
amn
2010-02-16 16:23:36