HTTP headers: Accept vs Content-Type
Published on in Miscellaneous
I sometimes forget what these two headers do in requests vs responses, so here's a refresher for me.
Acceptin request headers
- What type of response the client expects from the server.
Acceptin response headers
Content-Typein request headers
- The type of the request data (e.g. in a POST or PUT request).
Content-Typein response headers
- The type of the response data.
Content-Type header is usually not needed
if the request or response has no data
(e.g. GET requests and 204 No Content responses).
But apparently "some servers may require you to provide a
Content-Type [header] in a request even if the request has no payload."