Consider an HTTP request that gets the following response:
405 Method Not Allowed
Content-Length: 0
What should the content-type of something like this be?
text/plain
or text/html
The Content-Type representation header is used to indicate the original media type of the resource (prior to any content encoding applied for sending). In responses, a Content-Type header provides the client with the actual content type of the returned content.
Nope, Content-Type is not a required field. It's not mandatory per the HTTP 1.1 specification. Any HTTP/1.1 message containing an entity-body SHOULD include a Content-Type header field defining the media type of that body.
The text/html content type is an Internet Media Type as well as a Multipurpose Internet Mail Extensions (MIME) content type. Using HTML in MIME messages allows the full richness of Web pages to be available in e-mail.
You haven't got any content, therefore I wouldn't set a Content-Type
at all. If you find that causes problems to clients (which seems unlikely, to be honest), I'd probably go with text/plain
- definitely not text/html
, as your "empty content" is not an HTML document.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With