Sobes.tech
Intern

The client sends a request with the header Accept: application/json, but the server responds with Content-Type: text/html. What does this mean? - The server violated the HTTP protocol - The server ignored the client's preference and returned an available format - The client must reject such a response - This is only possible in case of a proxy error

sobes.tech AI

Answer from AI

If a client sends the header Accept: application/json, it informs the server that it prefers to receive a response in JSON format. However, if the server responds with the header Content-Type: text/html, that is, it returns HTML.

This is not necessarily a protocol violation. The server may ignore the client's preference and return a format it has or considers appropriate. In the HTTP protocol, there is no strict requirement that the server must strictly follow the Accept header — it is a recommendation.

The client is not obliged to reject such a response but should understand that the response format differs from what was expected.

A proxy error is not the only reason for such behavior; it is quite possible on the server side as well.

Correct answer: The server ignored the client's preference and returned an available format.

The client sends a request with the header Accept… - sobes.tech