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.

Accept in request headers
What type of response the client expects from the server.
Accept in response headers
N/A
Content-Type in request headers
The type of the request data (e.g. in a POST or PUT request).
Content-Type in response headers
The type of the response data.

The 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."