当未指定此标头时,浏览器如何知道内容类型? [英] How does browser know the content type when such header is not specified?

查看:276
本文介绍了当未指定此标头时,浏览器如何知道内容类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果服务器没有发送内容类型标题,浏览器如何判断他收到了哪种内容?例如,当我获得带有chrome的 SO徽标时,图像完好无损,服务器没有说明它的扩展名(至少是显式的)

if the server doesn't send the content-type header, how does the browser tell which kind of content he got? For example, when I get the SO logo with chrome, the image is intact, though the server doesn't state its extension (at least, explicitly)

推荐答案

如果类型没有明确指出,大多数浏览器会进行内容嗅探在HTTP标头中声明。他们正在寻找他们知道的特定签名,从而猜测媒体类型。

Most browsers do content sniffing if the type is not explicitly declared in the HTTP header. They are looking for specific signatures they know and thereby guess the media type.

参见 在HTML 5规范中确定浏览上下文中新资源的类型 或此 内容类型处理模型草案

这篇关于当未指定此标头时,浏览器如何知道内容类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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