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

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

问题描述

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 (Compatible MSIE 9.0;Windows NT 6.1;WOW64; Trident/5.0)

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?

解决方案

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.

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

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.

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

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天全站免登陆