38

I am learning HTTP. I enclose a request payload in XML or JSON format in my POST requests. What I wanted to know is whether a request payload and request body mean the same thing?

2
  • 1
    Please close your question by clicking the checkmark to the left of the answer that helped you most
    – Satyam
    Oct 11, 2017 at 5:37
  • The most helpful answer does not necessarily completely fulfil the question itself. Jun 10, 2021 at 17:14

6 Answers 6

19

Definition of: payload : The "actual data" in a packet or file minus all headers attached for transport and minus all descriptive meta-data. In a network packet, headers are appended to the payload for transport and then discarded at their destination.

Edit: In Http protocol, an http packet has http headers and http payload.So payload section of http packet may or may not have a body depending upon the type of request (e.g. POST vs GET). So payload and body are not the same thing.

7
  • 4
    @Dejel : Payload doesn't include headers and meta data info
    – Satyam
    Jan 5, 2016 at 10:20
  • 1
    Source for this definition please? Nov 22, 2016 at 22:29
  • 2
    @Flawyte en.wikipedia.org/wiki/Payload_(computing) In computing and telecommunications, the payload is the part of transmitted data that is the actual intended message. The payload excludes any headers or metadata sent solely to facilitate payload delivery.[
    – Satyam
    Nov 25, 2016 at 9:27
  • 2
    Downvoted because this doesn't explicitly answer the question - is payload and body the same think
    – tepez
    May 28, 2018 at 10:17
  • @tepez : In Http protocol, an http packet has http headers and http payload.So payload section of http packet may or may not have a body depending upon the type of request (e.g. POST vs GET). So payload and body are not the same thing.
    – Satyam
    May 29, 2018 at 14:05
10

Payload is the "wrapper" to the body

Payload is something one carries. A paperboy's payload is a pile of newspapers and a HTTP POST request's payload is whatever comes in the "body".

5
  • I'm interpreting this as if with request payload and request body people mean the same thing, is that what you meant? One can use payload and body interchangeably?
    – KajMagnus
    Jul 13, 2015 at 2:17
  • No. the payload contains the body
    – Dejell
    Jul 13, 2015 at 9:17
  • What constitute the payload then? The headers + the body? Or something more? In this HTTP request: GET /abc \n Content-Length:3 \n\n 123 — hmm isn't the payload 123 == the body?
    – KajMagnus
    Jul 13, 2015 at 14:53
  • payload is everything that you are sending. including the headers. not sure where the 123 comes from. usually GET requests do not contain body
    – Dejell
    Jul 13, 2015 at 16:45
  • Take a letter as example: the text written on the sheet is the PAYLOAD, while the stamp is the headers. Headers needs to delivery the letter, but does not contain the message inside (payload). Sep 28, 2017 at 8:23
5

What I wanted to know is whether a request payload and request body mean the same thing?

No, they have different meanings: content (a.k.a. payload) is a part of a representation (semantic concept) whereas a body is a part of a message (syntactic concept). A representation is transferred as a single message enclosing the complete representation, or as multiple messages enclosing the partial representations. A representation comprises metadata and data. A message comprises a start line, field lines enclosing representation metadata, and a body enclosing representation data (the content) as is or transfer-encoded.

                         +--------+  +----+
complete representation: |metadata|, |data|
                         +--------+  +----+
                              \         \
                          +--------+  +-------+
partial representation 1: |metadata|, |content|
partial representation 2: |metadata|, |content|
…                         |        |  |       |
partial representation N: |metadata|, |content|
                          +--------+  +-------+
                              /          /
                       +-----------+  +----+
message 1: start line, |field lines|, |body|
message 2: start line, |field lines|, |body|
…                      |           |  |    |
message N: start line, |field lines|, |body|
                       +-----------+  +----+

References

RFC 9110: HTTP Semantics defines the term representation:

3.2. Representations

A "representation" is information that is intended to reflect a past, current, or desired state of a given resource, in a format that can be readily communicated via the protocol. A representation consists of a set of representation metadata and a potentially unbounded stream of representation data (Section 8).

Notice that the definition is independent of the version of HTTP because it is about semantics.

RFC 9112: HTTP/1.1 defines the term message:

2.1. Message Format

An HTTP/1.1 message consists of a start-line followed by a CRLF and a sequence of octets in a format similar to the Internet Message Format [RFC5322]: zero or more header field lines (collectively referred to as the "headers" or the "header section"), an empty line indicating the end of the header section, and an optional message body.

HTTP-message   = start-line CRLF
                 *( field-line CRLF )
                 CRLF
                 [ message-body ]

Notice that the definition depends on the version of HTTP because it is about syntax.

RFC 9110: HTTP Semantics defines the term content:

6.4. Content

HTTP messages often transfer a complete or partial representation as the message "content": a stream of octets sent after the header section, as delineated by the message framing.

This abstract definition of content reflects the data after it has been extracted from the message framing. For example, an HTTP/1.1 message body (Section 6 of [HTTP/1.1]) might consist of a stream of data encoded with the chunked transfer coding -- a sequence of data chunks, one zero-length chunk, and a trailer section -- whereas the content of that same message includes only the data stream after the transfer coding has been decoded; it does not include the chunk lengths, chunked framing syntax, nor the trailer fields (Section 6.5).

Note: Some field names have a "Content-" prefix. This is an informal convention; while some of these fields refer to the content of the message, as defined above, others are scoped to the selected representation (Section 3.2). See the individual field's definition to disambiguate.

RFC 9110: HTTP Semantics substitutes the term content for payload used in previous RFCs:

B.3. Changes from RFC 7231

[…]

The terms "payload" and "payload body" have been replaced with "content", to better align with its usage elsewhere (e.g., in field names) and to avoid confusion with frame payloads in HTTP/2 and HTTP/3. (Section 6.4)

0

Header identifies source & destination of the sent packet, whereas the actual data i.e Body is referred to as Payload

2
  • 1
    So what is the difference? Feb 11, 2021 at 22:09
  • Are you still looking for an answer? Feb 13, 2021 at 4:24
0

The start-line and HTTP headers of the HTTP message are collectively known as the head of the requests, whereas its payload is known as the body

So Yes, they are the same thing.

Got this from https://developer.mozilla.org/en-US/docs/Web/HTTP/Messages

-1

Payload of HTTP message is known as the body. link1

The HTTP message payload body is the information ("payload") part of the data that is sent in the HTTP Message Body (if any), prior to transfer encoding being applied. If transfer encoding is not used, the payload body and message body are the same thing! link2

So basically the only difference between HTTP message body and HTTP message payload body is encoding (but only if present). So generalizing the term request payload = request body.

Not the answer you're looking for? Browse other questions tagged or ask your own question.