200-901 Question 48
Select 3A developer is debugging an HTTP API response from a web server and receives the following response:
HTTP/1.1 404 Not Found Content-Type: application/json Content-Length: 57
{"error": "Resource not found", "code": 404}
Which parts of this response correspond to the headers and the body?
- A
HTTP/1.1 404 Not Found is part of the headers.
- B
Content-Type: application/json is part of the headers.
- C
Content-Length: 57 is part of the headers.
- D
{"error": "Resource not found", "code": 404} is part of the body.
- E
HTTP/1.1 404 Not Found is part of the body.
Show answer and explanation
Correct answers: B, C, D
Explanation
An HTTP response consists of three main components: the status line, headers, and body. The status line (e.g., HTTP/1.1 404 Not Found) provides protocol version and response status information. Headers like Content-Type and Content-Length provide metadata about the response. The body contains the actual data being sent, such as the JSON payload in this example.
- A. Incorrect.
The HTTP status line (HTTP/1.1 404 Not Found) is not considered part of the headers. It is a separate component of the response message.
- B. Correct.
Content-Type: application/json is a header that specifies the media type of the response body.
- C. Correct.
Content-Length: 57 is a header that indicates the size of the response body in bytes.
- D. Correct.
{"error": "Resource not found", "code": 404} represents the body of the HTTP response, which contains the actual data sent by the server.
- E. Incorrect.
HTTP/1.1 404 Not Found is not part of the body. It is the status line, which is distinct from both headers and body.