在实践中,浏览器和服务器是否正在使用HTTP内容协商? [英] Is HTTP content negotiation being used by browsers and servers in practice?

查看:262
本文介绍了在实践中,浏览器和服务器是否正在使用HTTP内容协商?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在了解 HTTP内容协商此时此刻。我已经理解了客户端和服务器能够协商所请求内容的表示的基本方式。

I'm learning about HTTP content negotiation at the moment. I already understand the basic way client and server are able to negotiate a representation for the content requested.

我无法找到,但实际上内容协商是什么? >适合。 现实世界的浏览器是否正在积极使用这些?我知道他们正在发送一些标题,例如接受但是它们的内容和含义似乎模糊地定义为。

I could not find out, though, what content negotiation is actually good for. Are real world browsers actively using any of this? I understand they are sending some headers such as Accept but their content and meaning seems vaguely defined to be.

我也想知道现实世界的Web应用程序是否可以使用HTTP内容协商。 现实的Web应用程序是否会根据这些标头返回不同的数据?服务器如何基于 q-factor 来有意义地决定?

I also wonder if real-world web applications can make use of HTTP content negotiation. Would a realistic web application ever return different data based on these headers? How could a server meaningfully decide based on the q-factor?

我的目标是了解真正的网络应用程序在这方面的工作原理,以便我可以更好地决定我想要学习和使用的HTTP内容协商的哪些部分。

My goal is to understand how real web apps work in this regard so that I can better decide which parts of HTTP content negotiation I want to learn and use.

也许答案只是在实践中没有使用这对我来说是一个有效的答案。用例的具体示例也会有所帮助。

Maybe the answer is just that this is not being used in practice which would be a valid answer to me. Concrete examples for use cases would also help.

推荐答案

它肯定会被大量使用,例如协商格式(使用接受) ,例如image / webp),压缩编码(使用Accept-Encoding,例如brotli)或不同的语言(使用Accept-Language)。

It's definitely used a lot, for instance to negotiate formats (using "Accept", such as for image/webp), compression codings (using "Accept-Encoding", such as for brotli) or different languages (using "Accept-Language").

这篇关于在实践中,浏览器和服务器是否正在使用HTTP内容协商?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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