缺少MIME类型时返回什么(如果有)http状态代码? [英] What (if any) http status code is returned when a MIME type is missing?

查看:89
本文介绍了缺少MIME类型时返回什么(如果有)http状态代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果Web服务器没有为客户端尝试下载的文件添加MIME类型,将返回什么(如果有)http状态代码?

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?

这表明它可能是415,虽然答案不明确:

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

HTTP状态代码用于未接受的Content-Type in request

推荐答案

如果您的问题是请求的正确状态代码是什么,如果请求的主体是以服务器无法接受的媒体类型进行内容编码的,则答案是415不支持的媒体类型 。

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和draft-ietf-httpbis-p2-semantics-21.txt说:

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


如果请求消息中的实体的内容编码不是原始服务器可接受的
,则服务器应该以

的状态代码响应415(不支持的媒体类型)。

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).

但如果您的问题是如果服务器无法响应接受请求标头请求的媒体类型内容编码的实体主体,那么正确的状态代码是什么,答案是406不可接受

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说:

RFC 2616 says:


如果没有接受头字段存在,然后假设

客户端接受所有媒体类型。如果存在Accept头字段,
并且如果服务器无法根据组合的Accept字段值发送可接受的响应

,则服务器应该发送
发送406(不接受)回复。

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.

这篇关于缺少MIME类型时返回什么(如果有)http状态代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆