HTTP Accept vs Content-Type Header

 I am always confused between these 2 HTTP headers - which one is sent/consumed by the server and which one by the client?


Accept Header

The Accept header is set by the client to indicate the media type of the response that it can accept.


Content-Type Header

The Content-Type header is set by either on the request or the response, indicating the media type of the content of the current request. This header can be set by either client or the server, who ever is sending the request/response.


Some notes about these headers

- https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html has definitions of these and some other headers.

- A server is not required to honor the Accept header. The RFC states that it should send a 406 if it cannot produce the response type requested in the Accept header, but not all servers honor this.

Comments

Popular posts from this blog

Should you always have null checks?

Identity Terms and Definitions