简体   繁体   中英

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM