HTTP request header: UserAgent variable

后端 未结 2 959
名媛妹妹
名媛妹妹 2020-12-24 07:21

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 /

2条回答
  •  囚心锁ツ
    2020-12-24 07:55

    The Wikipedia article on User Agent states that:

    The User-Agent string format is currently specified by Section 14.43 of RFC 2616 (HTTP/1.1) The format of the User-Agent string in HTTP is a list of product tokens (keywords) with optional comments.

    So I recommend you read the RFC 2616 section about it:

    14.43 User-Agent

    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.

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

    Example:

       User-Agent: CERN-LineMode/2.15 libwww/2.17b3
    

    The section 4.8 about products token states the following:

    3.8 Product Tokens

    Product tokens are used to allow communicating applications to
    identify themselves by software name and version. Most fields using
    product tokens also allow sub-products which form a significant part
    of the application to be listed, separated by white space. By
    convention, the products are listed in order of their significance
    for identifying the application.

       product         = token ["/" product-version]
       product-version = token
    

    Examples:

       User-Agent: CERN-LineMode/2.15 libwww/2.17b3
       Server: Apache/0.8.4
    

    Product tokens SHOULD be short and to the point. They MUST NOT be
    used for advertising or other non-essential information. Although any token character MAY appear in a product-version, this token SHOULD
    only be used for a version identifier (i.e., successive versions of
    the same product SHOULD only differ in the product-version portion of the product value).

    So according to the RFC 2616, the contents of the User Agents is up to the browser. For instance, here is how Mozilla Firefox builds its user agent: https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference

提交回复
热议问题