What should the Content-Type be for a 4xx error without a body?

二次信任 提交于 2019-12-05 12:15:35

问题


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 or text/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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!