HTTP请求标头:UserAgent变量 [英] HTTP request header: UserAgent variable

查看:768
本文介绍了HTTP请求标头:UserAgent变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

发送HTTP请求时,IE会将User-Agent变量发送到服务器。一个可能的值(由网络调试器看到):

When sending a HTTP request, IE sends the User-Agent variable to the server. A possible value (as seen by the network debugger):


User-Agent:Mozilla /5.0(兼容的MSIE 9.0; Windows NT 6.1; WOW64;
Trident / 5.0)

User-Agent: Mozilla /5.0 (Compatible MSIE 9.0;Windows NT 6.1;WOW64; Trident/5.0)

我的问题:IE(或任何其他浏览器)如何找到这个变量?
我问这个是因为在访问某些网站时,这个变量与其他网站不同,我想跟踪变化的来源。 兼容性设置是一种选择,但我认为还有更多选择。

My question: How does IE (or any other browser) find out this variable? I'm asking this because when visiting some websites, this variable is different than others and I'd like to trace where the change is coming from. 'Compatibility settings' is one option, but I think there is more to it.

任何人都可以解释这个变量的过程吗?

Can anyone explain the process of this variable?

推荐答案

User-Agent出现在HTTP请求标头中,而不是HTTP响应标头。通常,请求从浏览器发送到Web应用程序。因此,用户代理变量由浏览器填充。不同的浏览器会使用不同的值填充此字段。

The User-Agent appears in an HTTP Request Header, not an HTTP Response one. In general, the request is sent from browser to the web application. So the user-agent variable is filled by the browser. Different browsers will fill up this field with different values.

关于IE如何找到这些变量,我想你问的是用户代理注册表键

About how IE find those variables, I think you are asking about User-Agent Registry Keys.

您还可以覆盖某些令牌通过向以下注册表项添加值来设置用户代理字符串。

You can also override certain tokens of the user-agent string by adding values to the following registry key.

HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
   SOFTWARE
      Microsoft
         Windows
            CurrentVersion
               Internet Settings
                  5.0
                     User Agent
                        (default) = "Mozilla/4.0"
                        Compatible = "compatible"
                        Platform = "Windows NT 5.1"
                        Version = "MSIE 6.0"
                        Pre Platform
                           Token = Value
                        Post Platform
                           Token = Value

用户代理密钥的默认值替换用户报告的应用程序名称和应用程序版本标记-agent字符串。请注意,前七个字符用于应用程序名称,其余字符指定应用程序版本令牌。

The default value of the User Agent key replaces the application name and application version tokens reported in the user-agent string. Be aware that the first seven characters are used for the application name, and the remaining characters specify the application version token.

Compatible,Platform和Version值替换相应的用户代理字符串中的标记。

The Compatible, Platform, and Version values replace the corresponding tokens in the user-agent string.

可以使用注册表编辑器在Pre-Platform项下创建新的字符串值,从而将其他标记添加到用户代理字符串中或后平台密钥。值名称应该是完整的标记;值数据被忽略。添加到Pre-Platform密钥的标记出现在最终用户代理字符串中的平台标记之前。添加到Post-Platform密钥的标记出现在最终用户代理字符串中的平台标记之后。 Pre-Platform键或Post-Platform键中的多个令牌以不可预测的顺序显示。

Additional tokens can be added to the user-agent string by using the Registry Editor to create new string values under the Pre-Platform key or Post-Platform key. The value name should be the complete token; the value data is ignored. Tokens added to the Pre-Platform key appear before the platform token in the final user-agent string. Tokens added to the Post-Platform key appear after the platform token in the final user-agent string. Multiple tokens in either the Pre-Platform key or Post-Platform key are displayed in an unpredictable order.

这篇关于HTTP请求标头:UserAgent变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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