What is a payload?

Asked

Viewed 26,195 times

45

I’ve always seen in some frameworks that work with REST or with sending data in JSON format in a request using the expression payload.

  • What does that name mean in HTTP requests?

  • What is specifically a payload? It is a body of a request in JSON format?

An example of the term being used by Google Chrome:

Example 1:

Imagem do  Google Chrome indicando o nome Payload

Example 2:

  • Payload in terms of hacking is a script that is injected into a system through some failure and then runs as a sort of remote administration. I just think the term you’re looking for is in another context.

  • The formal and most used name in the HTTP context is not payload but yes "body", in Portuguese "body". "Payload" in turn is widely used in message queueing.

  • @Caffé do not know if it is well not, huh. See this question on SOEN

  • 2

    @Wallacemaxters This SOEN response links the RFC not yet approved. The current specification is: https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html. The new RFC calls "everything" payload, dividing between "payload header fieds" and "payload body"; which is cool because header fields can also contain relevant application information and not just transport data.

  • On the second question: yes, in HTTP the payload body can be a JSON, which is quite common in the REST Apis today. But it can also be an XML, a key-value dictionary of the fields of an HTML form, the HTML of a page itself, or anything else. Note that the "payload header Fields", in turn, although also called "payload" in the future RFC, cannot contain JSON, or should not otherwise cause a nice mess in the header and escape the header’s default and proposal.

4 answers

49


It would be the data that really matters without metadata, without the transmission header or other ancillary information used only as infrastructure to convey what matters. So he is the body of information, is what is useful of all that is being transmitted.

The literal translation "payload" could be called "worthwhile content".

Meaning may be different in other contexts, even computing.

Example of TCP package (I didn’t find a good HTTP, but the idea is similar). Data (green) is the payload:

Pacote TCP

In another question has a diagram showing the various layers of communication and all have headers that are being added in each layer and the "data" part, which is the one of the payload. If the payload is very small the overhead of the headers of all layers becomes a burden. You may have some control over the size of the payload in high layer, but in the lowest the control will get smaller, payloads very large tend to be sliced before they are transmitted.

The payload has no text or binary format. The fact of being JSON is only circumstantial. In HTTP it is even text by protocol imposition, but it can be HTML, CSS, JS, raw text, binary encoded in Base64, etc..

  • 5

    Example HTTP message: https://www.ntu.edu.sg/home/ehchua/programming/webprogramming/images/HTTP_RequestMessageExample.png (no further comments on the answer to not bother you hehe).

20

In general terms, the payload ("cargo" is the content sent by a means of transport, or Carrier. Some examples:

  • The content HTML is the payload sent via protocol HTTP;
  • The content JSON is the payload sent via protocol HTTP from the endpoint REST*;
  • The content XML is the payload sent via protocol HTTP from the endpoint SOAP*.

In some terminologies the Carrier is also called envelope.

*For example purposes only. REST and SOAP endpoints can generate payloads in other formats.

  • 2

    From the point of view of HTTP, HTML (or any other sequence of bytes carried) would be payload. However, from the point of view of the application as a whole, the structure of HTML, JSON and XML would be carriers, while the carried load would be the data that is represented and structured in this HTML, JSON or XML.

  • @Victorstafusa yes, exactly - it is a question from the point of view of the consumer layer.

2

Payload in terms of protocol is nothing less than its content. For example, the Payload of an IP protocol may be TCP. That is, roughly it is what represents the data to be transported by the protocol. It is the same with HTTP and Json. And the payload presented in this context is what will be transported in the request Json.

-2

Payload in the context of your question is exactly how Onosendai answered, which means the entire JSON shown from your example. It’s always in the context of the question. I usually understand how to payload the extra charge that needs to be carried when there is an authentication and authorization control by token, as for example in JWT, in this case in addition to the traffic record you need to traffic the token and the faithful copy of the data then again to make a POST for example, thus being an "extra charge", payload, to traffic the load you are obliged to also traffic the token and its dependency, pay a load, so it’s also called PAYLOAD. Confused? But at the end of the accounts in your context payload is all that comes in the JSON shown, the data and the token if any.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.