Skip to content

Instantly share code, notes, and snippets.

@justdoit0823
Last active January 6, 2018 12:16
Show Gist options
  • Save justdoit0823/bdfa89817dde5a9ab279f612559a610e to your computer and use it in GitHub Desktop.
Save justdoit0823/bdfa89817dde5a9ab279f612559a610e to your computer and use it in GitHub Desktop.
A comparision between http message and entity.

Message

HTTP messages consist of requests from client to server and responses from server to client.

HTTP-message   = Request | Response     ; HTTP/1.1 messages
generic-message = start-line
                  *(message-header CRLF)
                  CRLF
                  [ message-body ]
start-line      = Request-Line | Status-Line

Message Header

HTTP header fields, which include general-header (section 4.5), request-header (section 5.3), response-header (section 6.2), and entity-header (section 7.1) fields, follow the same generic format as that given in Section 3.1 of RFC 822 [9].

message-header = field-name ":" [ field-value ]
field-name     = token
field-value    = *( field-content | LWS )
field-content  = <the OCTETs making up the field-value
                 and consisting of either *TEXT or combinations
                 of token, separators, and quoted-string>

Multiple message-header fields with the same field-name MAY be present in a message if and only if the entire field-value for that header field is defined as a comma-separated list [i.e., #(values)].

Message Body

The message-body (if any) of an HTTP message is used to carry the entity-body associated with the request or response. The message-body differs from the entity-body only when a transfer-coding has been applied, as indicated by the Transfer-Encoding header field (section14.41).

message-body = entity-body | <entity-body encoded as per Transfer-Encoding>

Entity

Request and Response messages MAY transfer an entity if not otherwise restricted by the request method or response status code. An entity consists of entity-header fields and an entity-body, although some responses will only include the entity-headers.

Entity Header

Entity-header fields define metainformation about the entity-body or, if no body is present, about the resource identified by the request.

entity-header  = Allow | Content-Encoding | Content-Language | Content-Length | Content-Location | Content-MD5 | Content-Range | Content-Type | Expires | Last-Modified | extension-header
extension-header = message-header

Entity Body

The entity-body (if any) sent with an HTTP request or response is in a format and encoding defined by the entity-header fields.

entity-body    = *OCTET
entity-body := Content-Encoding( Content-Type( data ) )

An entity-body is only present in a message when a message-body is present, as described in section 4.3. The entity-body is obtained from the message-body by decoding any Transfer-Encoding that might have been applied to ensure safe and proper transfer of the message.

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment