问题
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?
- Set to nothing?
- Not set?
- Set to
text/plain
ortext/html
回答1:
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.
来源:https://stackoverflow.com/questions/15032932/what-should-the-content-type-be-for-a-4xx-error-without-a-body