Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 278
Chris Halcrow Avatar asked Oct 17 '13 03:10

Chris Halcrow


1 Answers

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.

like image 188
npcode Avatar answered Oct 18 '22 04:10

npcode