HTTP Payloads

 What happens when I send a letter without information to the receiver that I require some details from them? What happens when the receiver writes a response to my letter without having the information I need?

This information is similar to the body generally called a payload in HTTP request and response. 

Let us see the payload in the HTTP request and HTTP response individually.

I have added the below image to explain the HTTP request and response body/payload in JSON. I have used BurpSuite to take this image and Swagger Petstore (petstore.swagger.io) for this example.



HTTP Request Payload

  • Generally, the payload is not required for all the requests and responses.
  • GET and HEAD methods usually do not require a body while sending a request to the server.
  • The above example is a POST request to create a resource name 'doggie'. To achieve this, I should send some information about the resource which is called HTTP request payload.
  • Breakdown of request payload:
    • Content-Type: Specifies what kind of format is acceptable from the server.
    • Data: The actual content or data being transmitted, formatted according to the specified content type.
    • Size: The size of the payload, usually measured in bytes, can affect network performance and server processing. Large payloads may require more bandwidth and server resources to process.
    • Transmission: The request payload is typically sent in the body of the HTTP request, following the request headers. In POST requests, for example, the payload is included after the request headers and separated from them by a blank line. 
HTTP Response Payload
  • Similarly, the server does not always have a body when sending the response like 201-Created, 204-No Content.
  • In the mentioned example, the server responded with the body that the resource was created with the name 'doggie'. It sends the information added when creating a resource in the server. This makes sure the client that all the provided information has been updated on the server.
  • Breakdown of response payload:
    • Content-Type: Mentions the format in which the server responds to the client.
    • Data: The actual content or data transmitted from the server to the client. For example: 
      • In response to an HTTP GET request for a webpage, the payload might contain an HTML markup for rendering the webpage in the client's browser.
      • In an API response, the payload might contain JSON or XML data with the requested information.
    • Size: Similar to the HTTP request payload, the size of the response payload is measured in bytes. 
    • Transmission: The response payload is typically included in the body of the HTTP response, following the response headers. It is sent after the headers and separated from them by a blank line same as the HTTP request payload.
I hope it is easy to understand. Let me know in the comments if you have any thoughts.

    

Comments

Popular posts from this blog

How to Install Jenkins

Variables in Postman