Do I need a content-type header for HTTP GET requests?
GET requests can have "Accept" headers, which say which types of content the client understands. The server can then use that to decide which content type to send back.
They're optional though.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
According to the RFC 7231 section 3.1.5.5:
A sender that generates a message containing a payload body SHOULD generate a Content-Type header field in that message unless the intended media type of the enclosed representation is unknown to the sender. If a Content-Type header field is not present, the recipient MAY either assume a media type of "application/octet-stream" ([RFC2046], Section 4.5.1) or examine the data to determine its type.
It means that the Content-Type
HTTP header should be set only for PUT
and POST
requests.
Get requests should not have content-type because they do not have request entity (that is, a body)
The accepted answer is wrong. The quote is correct, the assertion that PUT and POST must have it is incorrect. There is no requirement that PUT or POST actually have additional content. Nor is there a prohibition against GET actually having content.
The RFCs say exactly what they mean .. IFF your side (client OR origin server) will be sending additional content, beyond the HTTP headers, it SHOULD specify a Content-Type header. But note it is allowable to omit the Content-Type and still include content (say, by using a Content-Length header).