浏览器的User-Agent字符串的标准格式是什么?

What is the standard format for a browser's User-Agent string?

是否有用于创建用户代理字符串的RFC、官方标准或模板?iPhone的用户代理字符串看起来很奇怪…

Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7D11 Safari/528.16

< /块引用>


User-Agent头是RFC2616的一部分,是RFC1945的改进版本,其中说明:

The User-Agent request-header field contains information about the
user agent originating the request. This is for statistical purposes,
the tracing of protocol violations, and automated recognition of user
agents for the sake of tailoring responses to avoid particular user
agent limitations. User agents SHOULD include this field with
requests. The field can contain multiple product tokens (section 3.8)
and comments identifying the agent and any subproducts which form a
significant part of the user agent. By convention, the product tokens
are listed in order of their significance for identifying the
application.

1
   User-Agent     ="User-Agent"":" 1*( product | comment )

其中,product定义为:

1
2
3
   product         = token ["/" product-version]
   product-version = token
   token           = 1*

comment作为:

1
2
   comment        ="(" *( ctext | quoted-pair | comment )")"
   ctext          =


这在请求标题部分的RFC1945中有规定。但是,它不是一种非常标准的格式,用户代理倾向于将他们想要的任何内容放在其中。


是的,请参见:Mozilla网站,但正如前面提到的那样。基本上你可以把你想要的放在那里。出于统计/分析目的,最重要的是,每个浏览器/操作系统都应该有自己的标准化。