What (if any) http status code is returned when a MIME type is missing?

女生的网名这么多〃 提交于 2019-12-08 19:39:39

问题


If a web server doesn't have a MIME type added for a file that a client tries to download, what (if any) http status code would be returned?

It suggests here it could be 415, although the answer isn't definite:

HTTP status code for unaccepted Content-Type in request


回答1:


The answer is "415 Unsupported Media Type" if your question is "what is the correct status code for a request if its body is content-encoded in the media type the server cannot accept."

RFC 2616 and draft-ietf-httpbis-p2-semantics-21.txt says:

If the content-coding of an entity in a request message is not
acceptable to the origin server, the server SHOULD respond with a
status code of 415 (Unsupported Media Type).

But If your question is "what is the correct status code if the server cannot respond with an entity body which is content-encoded in the media-type requested by Accept request header", the answer is "406 Not Acceptable"

RFC 2616 says:

If no Accept header field is present, then it is assumed that the
client accepts all media types. If an Accept header field is present, and if the server cannot send a response which is acceptable
according to the combined Accept field value, then the server SHOULD
send a 406 (not acceptable) response.



来源:https://stackoverflow.com/questions/19417553/what-if-any-http-status-code-is-returned-when-a-mime-type-is-missing

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