DJ-coding
DJ-coding

Reputation: 323

Charles, empty request body with non-empty response body

I used Charles to record a session and when I check one of the sessions, I found that there is no request body but I can see a response body, I am confused about this as how am I seeing a response without sending a request?

enter image description here

enter image description here

Also, I noticed that I can choose to see the request and response body on my phone's Charles, but on my desktop Charles, I can only see the tab called Content, I tried clicking on the request and response in the under the View tab, nothing happened as well. Does anyone know why? enter image description here

Thanks!

Upvotes: 0

Views: 1190

Answers (1)

Tim Perry
Tim Perry

Reputation: 13256

I am confused about this as how am I seeing a response without sending a request?

A request consists of a few things:

  • Always: an HTTP method (GET, POST, or similar)
  • Always: a path (/document/123)
  • Optional: any number of HTTP headers (my-header: abc)
  • Optional: a request body

A response consists of:

  • Always: an HTTP status (404)
  • Always (in HTTP/1): an HTTP status message (Not Found)
  • Optional: any number of HTTP headers (my-header: abc)
  • Optional: a response body

In your case, you are sending a request, it's just that your request only contains a method, URL and headers, but no body. That's totally normal and this is very common for most HTTP requests.

The request and response body are totally independent: it's fine for neither to have a body, or for just one (either one) to have a body, or for both to have a body.

As an example, a GET request to https://google.com/search from a browser will include a method (GET) and a path (/search) and a selection of headers from the browser (such as a user-agent), but won't include any body, and the response will have a status (200) and message (OK), headers about the response data (e.g. content-length: ...) and the body will be the HTML for the google search page.

Upvotes: 1

Related Questions